diff --git a/README.md b/README.md index dbea79c..3e538fb 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,8 @@ npm install @meforma/vue-toaster ## Import +You can install Toaster so it's usable globally: + ```js // In you main.js // ... considering that your app creation is here @@ -24,6 +26,16 @@ import Toaster from "@meforma/vue-toaster"; createApp(App).use(Toaster).mount("#app"); ``` +You can also import Toaster locally: + +```js +import { createToaster } from "@meforma/vue-toaster"; + +const toaster = createToaster({ /* options */ }); + +toaster.show(`Hey! I'm here`); +``` + ## Usage ```js diff --git a/src/index.js b/src/index.js index 5793e12..1069bf1 100644 --- a/src/index.js +++ b/src/index.js @@ -1,9 +1,9 @@ import Toaster from './Toaster.vue' -import Api from './api.js' +import createToaster from './api.js' import Positions from './defaults/positions.js' const Plugin = (app, options = {}) => { - let methods = Api(options) + let methods = createToaster(options) app.$toast = methods app.config.globalProperties.$toast = methods } @@ -11,4 +11,4 @@ const Plugin = (app, options = {}) => { Toaster.install = Plugin export default Toaster -export { Toaster, Positions } +export { Toaster, Positions, createToaster }