1.0.1 • Published 2 years ago

nuxt-events v1.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

Nuxt-Events

npm version npm downloads License

My new Nuxt module

Features

  • 🚠  Simple Event bus

Setup

  1. 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
  1. Add my-module to the modules section of nuxt.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

  1. Import the module in your page or component: const { $events } = useNuxtApp()
  2. Define your event handler:
const eventHandler = () => {
  // Do something awesome
}

$events.on('${THE_NAME_OF_YOUR_EVENT}', eventHandler)
  1. 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
1.0.1

2 years ago

1.0.0

2 years ago