killmenot / vue3-vt-notifications

A headless vue3 notification library to use with tailwind
MIT License
22 stars 3 forks source link

Composition API #1

Open wadimsewo opened 3 years ago

wadimsewo commented 3 years ago

Hi, how is it accessible in the composition API?

Best greets, Wadim

killmenot commented 3 years ago

Hi,

Haven't thought about it yet. I will research it once I have some free time

killmenot commented 3 years ago

Is it something similar you would like to see? https://vuedose.tips/create-a-i18n-plugin-with-composition-api-in-vuejs-3/

NoahCardoza commented 2 years ago

@wadimsewo I did it by creating a file to wrap methods.notify like this:

notify.js

import { methods } from 'vue3-vt-notifications/src/notifications.js'

export default methods.notify.bind(methods)

And then, I accessed it in my setup like:

Component.vue

<template>
  <div @click="onClick">Click me!</div>
</template>

<script>
import notify from './notify';

export default {
  setup(){
    const onClick = () => notify({
        type: 'success',
        title: 'Congrats!',
        text: 'You clicked me!',
    }, 3000);

   return { onClick };
  }
}
</script>

<style>
</style>
vishvendrasingh commented 2 years ago

Above solution isn't working for me don't know why!

vishvendrasingh commented 2 years ago

I also tried below in setup but it just doesn't work for me!

import { getCurrentInstance } from 'vue' const app = getCurrentInstance() app.appContext.config.globalProperties.$notify( { type: 'success', title: 'Congrats!', text: 'You clicked me!', }, 3000 )

ghost commented 2 years ago

@vishvendrasingh, try this fork of notifications library https://github.com/emmanuelsw/notiwind.