From 3a4712e21a7310f38a6465f88099f7ba65359a6c Mon Sep 17 00:00:00 2001 From: Luca Ban Date: Fri, 1 Oct 2021 16:22:36 +0900 Subject: [PATCH 1/2] proposal: allow programmatic creation of Toaster --- src/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 } From d05b439056e0461a7f645cc5ec50ec5cbb7a0cb7 Mon Sep 17 00:00:00 2001 From: Luca Ban Date: Fri, 1 Oct 2021 16:26:18 +0900 Subject: [PATCH 2/2] document local import method --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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