1.0.1 • Published 2 years ago
nuxt-events v1.0.1
Nuxt-Events
My new Nuxt module
Features
- 🚠 Simple Event bus
Setup
- Add
nuxt-events
dependency to your project
# Using pnpm
pnpm add nuxt-events
# Using yarn
yarn add nuxt-events
# Using npm
npm install nuxt-events
- Add
my-module
to themodules
section ofnuxt.config.ts
export default defineNuxtConfig({
modules: [
'nuxt-events'
]
})
That's it! You can now use nuxt-events
in your Nuxt app ✨
How to use this module
- Import the module in your page or component:
const { $events } = useNuxtApp()
- Define your event handler:
const eventHandler = () => {
// Do something awesome
}
$events.on('${THE_NAME_OF_YOUR_EVENT}', eventHandler)
- Emit your event:
$events.emit('${THE_NAME_OF_YOUR_EVENT}')
Development
# Install dependencies
npm install
# Generate type stubs
npm run dev:prepare
# Develop with the playground
npm run dev
# Build the playground
npm run dev:build
# Run ESLint
npm run lint
# Run Vitest
npm run test
npm run test:watch
# Release new version
npm run release