Skip to main content

Quickstart

import { Module as EventsModule } from '@quik/events';

await EventsModule.setup({ /* bootstrap options */ });
import { QGlobalEventBus } from '@quik/events';

// Subscribe — returns an unsubscribe function
const off = QGlobalEventBus.on<{ userId: number }>('user.created', async ({ userId }) => {
console.log('New user:', userId);
});

// Emit
await QGlobalEventBus.emit('user.created', { userId: 42 });

// Unsubscribe
off();

Notes

  • QGlobalEventBus is a process-wide singleton; use QEventBus directly when you need an isolated bus.
  • Handler errors are caught and logged per-handler, so one failing subscriber never breaks others or the emitter.