Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including subscribr with all npm packages installed. Try it out:

var subscribr = require("subscribr")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

subscribr v2.1.4

A tiny event subscriber.

npm travis dependencies dev dependencies

API

Subscribr.on(eventId, handler)

Subscribe to an event.

Parameters

NameTypeDescription
eventIdstringthe event ID.
handlerfunctionthe callback function.

Returns

  • function Subscription destroyer.

Subscribr.one(eventId, handler)

Subcribe an evento to be executed only once (gets self-destroyed after execution).

Parameters

NameTypeDescription
eventIdstringthe event ID.
handlerfunctionthe callback function.

Returns

  • function Subscription destroyer.

Subscribr.emit(eventId, params)

Emit an event.

Parameters

NameTypeDescription
eventIdstringthe event ID.
paramsobjecthandler params.


Subscribr.listHandlers(eventId)

List an event's handlers.

Parameters

NameTypeDescription
eventIdstringthe event ID.

Returns

  • array Event handlers.

Subscribr.remove(eventId)

Unsubscribe an event.

Parameters

NameTypeDescription
eventIdstringthe event ID.


Subscribr.interceptors

Get interceptors.

Returns

  • array Interceptors.

Subscribr.events

Get events.

Returns

  • array Events.

Subscribr.all

Get all events and interceptors.

Returns

  • object Events.
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free