Skip to content

proposal: allow programmatic creation of Toaster #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 }