File tree Expand file tree Collapse file tree 1 file changed +19
-23
lines changed Expand file tree Collapse file tree 1 file changed +19
-23
lines changed Original file line number Diff line number Diff line change @@ -42,37 +42,33 @@ const NotificationStore = {
4242 clear ( ) {
4343 this . state = [ ]
4444 }
45+ } ;
46+
47+ function initStore ( Vue ) {
48+ return new Vue ( {
49+ data ( ) {
50+ return {
51+ notificationStore : NotificationStore
52+ }
53+ } ,
54+ methods : {
55+ notify ( notification ) {
56+ this . notificationStore . notify ( notification ) ;
57+ }
58+ }
59+ } ) ;
4560}
4661
4762const NotificationsPlugin = {
4863 install ( Vue , options ) {
49- Vue . mixin ( {
50- data ( ) {
51- return {
52- notificationStore : NotificationStore
53- }
54- } ,
55- methods : {
56- notify ( notification ) {
57- this . notificationStore . notify ( notification ) ;
58- }
59- }
60- } )
61- Object . defineProperty ( Vue . prototype , '$notify' , {
62- get ( ) {
63- return this . $root . notify
64- }
65- } )
66- Object . defineProperty ( Vue . prototype , '$notifications' , {
67- get ( ) {
68- return this . $root . notificationStore
69- }
70- } )
64+ let store = initStore ( Vue ) ;
65+ Vue . prototype . $notify = store . notify ;
66+ Vue . prototype . $notifications = store . notificationStore ;
7167 Vue . component ( 'Notifications' , Notifications )
7268 if ( options ) {
7369 NotificationStore . setOptions ( options )
7470 }
7571 }
76- }
72+ } ;
7773
7874export default NotificationsPlugin
You can’t perform that action at this time.
0 commit comments