Module

eventController

This controller implements pub/sub pattern and serves as a broker (event bus) between event emitter (publisher) and event consumer (subscriber). https://en.wikipedia.org/wiki/Publish%E2%80%93subscribe_pattern

View Source frontend/controllers/event_controller.js, line 22

Methods

# static publish(event, payload, waitAsync) → {Array}

This function calls all callbacks that subscribed to the specific event

Parameters:
Name Type Description
event EzraEvent

Event key to be notified

payload *
waitAsync Boolean

Whether or not the function should wait for the subscribers (default: false)

View Source frontend/controllers/event_controller.js, line 113

Array of callback results

Array

# static publishAsync(event, payload) → {Promise.<Array>}

This function calls all callbacks that subscribed to the specific event and awaits for all callbacks to finish

Parameters:
Name Type Description
event EzraEvent

Event key to be notified

payload *

View Source frontend/controllers/event_controller.js, line 137

Promise that resolves to array of callback results

Promise.<Array>

# static subscribe(event, callback, prioritize) → {Subscription}

This function subscribes callback to be called when future events are published

Parameters:
Name Type Description
event EzraEvent

Event key to be notified on publish

callback SubscribedCallback

Function to call when when event is published

prioritize Boolean

Whether or not this callback should be prioritized when the event is published

View Source frontend/controllers/event_controller.js, line 86

subscription

Subscription

# static subscribeMultiple(callback) → {Subscription}

This function subscribes on multiple events, so that the callback function gets called when any of those future events are published.

Parameters:
Name Type Description
callback SubscribedCallback

Function to call when events are published

View Source frontend/controllers/event_controller.js, line 64

subscription

Subscription

# static subscribePrioritized(event, callback) → {Subscription}

This function subscribes callback to be called when future events are published. The subscriber is handled with priority by inserting it on top of the subscriber list.

Parameters:
Name Type Description
event EzraEvent

Event key to be notified on publish

callback SubscribedCallback

Function to call when when event is published

View Source frontend/controllers/event_controller.js, line 54

subscription

Subscription

# static unsubscribeAll(event)

This function unsubscribes all callbacks from the specific event

Parameters:
Name Type Description
event EzraEvent | RegExp

Event key to unsubscribe, can be a RegExp

View Source frontend/controllers/event_controller.js, line 158

Type Definitions

# SubscribedCallback(payload)

Parameters:
Name Type Description
payload *

Optional payload

View Source frontend/controllers/event_controller.js, line 37

Object

# Subscription

Properties:
Name Type Description
remove function

Function to call to unsubscribe from the event

View Source frontend/controllers/event_controller.js, line 42