github clerk/javascript @clerk/shared@3.6.0

latest releases: @clerk/types@4.92.0, @clerk/clerk-js@5.99.0, @clerk/fastify@2.4.37...
6 months ago

Minor Changes

  • Export createEventBus from @clerk/shared/eventBus. (#5546) by @panteliselef

    // Create a type-safe event bus
    const bus = createEventBus<{
      'user:login': { id: string };
      error: Error;
    }>();
    
    // Subscribe to events
    const onLogin = ({ id }: { id: string }) => console.log('User logged in:', id);
    bus.on('user:login', onLogin);
    
    // Subscribe with priority (runs before regular handlers)
    bus.onBefore('error', error => console.error('Error occurred:', error));
    
    // Emit events
    bus.emit('user:login', { id: 'user_123' });
    
    // Unsubscribe specific handler
    bus.off('user:login', onLogin);
    
    // Unsubscribe all handlers
    bus.off('error');

Patch Changes

Don't miss a new javascript release

NewReleases is sending notifications on new releases.