Skip to content

Commit

Permalink
Merge pull request #23 from mesqueeb/patch-1
Browse files Browse the repository at this point in the history
proposal: allow programmatic creation of Toaster
  • Loading branch information
jprodrigues70 authored Oct 6, 2021
2 parents c63d675 + d05b439 commit 358d6c2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
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
}

Toaster.install = Plugin

export default Toaster
export { Toaster, Positions }
export { Toaster, Positions, createToaster }

0 comments on commit 358d6c2

Please sign in to comment.