diff --git a/package.json b/package.json index 292cdab..0febef6 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "test": "echo 'no tests!' && npm run lint", "prepublish": "npm run build", "lint": "xo", - "build": "bili --format cjs --format umd --compress --banner --js babel && node-sass themes/ -o themes/", + "build": "bili --external=vue --format cjs --format umd --compress --banner --js babel && node-sass themes/ -o themes/", "build:example": "poi build", "dev": "poi --port 5000", "deploy": "npm run build:example && gh-pages -d example/dist" @@ -29,6 +29,9 @@ "author": "cristij ", "license": "MIT", "dependencies": {}, + "peerDependencies": { + "vue": "^2.2.0" + }, "devDependencies": { "babel-preset-vue-app": "^2.0.0", "bili": "^0.16.0-rc.2", diff --git a/src/index.js b/src/index.js index 5644fb4..39e3e9d 100644 --- a/src/index.js +++ b/src/index.js @@ -1,4 +1,5 @@ import Notifications from './Notifications.js' +import Vue from 'vue'; const NotificationStore = { state: [], // here the notifications will be added @@ -59,16 +60,28 @@ function initStore(Vue){ }); } -const NotificationsPlugin = { - install (Vue, options) { - let store = initStore(Vue); - Vue.prototype.$notify = store.notify; - Vue.prototype.$notifications = store.notificationStore; - Vue.component('Notifications', Notifications) - if(options){ - NotificationStore.setOptions(options) - } - } +export const Notification = new class { + constructor(){ + this.store = initStore(Vue); + } + + notify(...params){ + this.store.notify(params) + } + + notifications(){ + return this.store.notificationStore; + } }; -export default NotificationsPlugin +export default { + install (Vue, options) { + let store = initStore(Vue); + Vue.prototype.$notify = store.notify; + Vue.prototype.$notifications = store.notificationStore; + Vue.component('Notifications', Notifications); + if(options){ + NotificationStore.setOptions(options) + } + } +}