AsyncEvents ⇐ events.EventEmitter

Kind: global class
Extends: events.EventEmitter
Classdec: Extends the core node events.EventEmitter so that it is promisified, blocking and with event priorities.

new AsyncEvents()

Creates a new AsyncEvents emitter.

asyncEvents.__on

Stores the old event on method.

Kind: instance property of AsyncEvents
See: https://nodejs.org/api/events.html#events_emitter_on_eventname_listener

asyncEvents.__emit

Stores the old event emit method.

Kind: instance property of AsyncEvents
See: https://nodejs.org/api/events.html#events_emitter_emit_eventname_args

asyncEvents.on(name, [priority], fn) ⇒ Promise

Reimplements event on method.

This optionally allows a priority to be specified. Lower priorities run first.

Kind: instance method of AsyncEvents
Returns: Promise - A Promise
Since: 3.0.0

Param Type Default Description
name String The name of the event
[priority] Integer 5 The priority the event should run in.
fn function The function to call. Should get the args specified in the corresponding emit declaration.

Example

// Print out all our apps as they get instantiated and do it before other `post-instantiate-app` events
lando.events.on('post-instantiate-app', 1, function(app) {
  console.log(app);
});

// Log a helpful message after an app is started, don't worry about whether it runs before or
// after other `post-start` events
return app.events.on('post-start', function() {
  lando.log.info('App %s started', app.name);
});

asyncEvents.emit(name, [...args]) ⇒ Promise

Reimplements event emit method.

This makes events blocking and promisified.

Kind: instance method of AsyncEvents
Returns: Promise - A Promise
Since: 3.0.0

Param Type Description
name String The name of the event
[...args] Any Options args to pass.

Example

// Emits a global event with a config arg
return lando.events.emit('wolf359', config);

// Emits an app event with a config arg
return app.events.emit('sector001', config);

results matching ""

    No results matching ""