Class: PaywallEventBus

PaywallEventBus(paywallHttpRequest)

new PaywallEventBus(paywallHttpRequest)

Private class in charge of maintaining all listeners for a in a payment flow. It allows for registration and un-registration of a listener and onEvent forwards the event to all matching listeners.
Parameters:
Name Type Description
paywallHttpRequest Paywall | object the related payment flow.
Source:

Methods

(static) addListener(name, type, callback)

Method to add a listener, if listener already exists with given name it will be updated.
Parameters:
Name Type Description
name string the unique name of the listener within this payment flow.
type PaywallEventType the type of event to listen to, or special ALL that receives all events.
callback function method that should be called on given event. The function should have two parameters one PaywallEventType and one object containing the object data. Type of object differs for each event.
Source:

(static) addListenerFirst(name, type, callback)

Method to add a listener to first position in eventBus, if listener already exists with given name it will be removed and the new callback will be added first.
Parameters:
Name Type Description
name string the unique name of the listener within this payment flow.
type PaywallEventType the type of event to listen to, or special ALL that receives all events.
callback function method that should be called on given event. The function should have two parameters one PaywallEventType and one object containing the object data. Type of object differs for each event.
Source:

(static) close()

Method to close underlying resources and background check.
Source:

(static) onEvent(type, object)

Method called when a given event occurred and the method forwards the event to a listeners that matches.
Parameters:
Name Type Description
type PaywallEventType the type of event that has been triggered.
object * related data object, different data depending on event type. For instance event type INVOICE will contain the invoice etc.
Source:

(static) removeListener(name)

Method to remove listener with given name if exists.
Parameters:
Name Type Description
name string the name of listener to remove.
Source:

(static) triggerEventFromState()

Method to trigger an event from the current status of the payment flow the event type and related object will be calculated automatically.
Source: