Mixin: Triggers

Triggers

Provides trigger functionality methods.
Source:

Methods

(private, static) _triggerIndexOf(id, type, phase) → {number}

Returns the index of a trigger by id based on type and phase.
Parameters:
Name Type Description
id String The id of the trigger to find the index of.
type Number The type of operation. See Mixin.Constants for constants to use.
phase Number The phase of the operation. See Mixin.Constants for constants to use.
Source:
Returns:
Type
number

(static) addTrigger(id, type, phase, method) → {boolean}

Add a trigger by id.
Parameters:
Name Type Description
id String The id of the trigger. This must be unique to the type and phase of the trigger. Only one trigger may be added with this id per type and phase.
type Number The type of operation to apply the trigger to. See Mixin.Constants for constants to use.
phase Number The phase of an operation to fire the trigger on. See Mixin.Constants for constants to use.
method function The method to call when the trigger is fired.
Source:
Returns:
True if the trigger was added successfully, false if not.
Type
boolean

(static) processTrigger(operation, type, phase, oldDoc, newDoc) → {boolean}

Processes trigger actions based on the operation, type and phase.
Parameters:
Name Type Description
operation Object Operation data to pass to the trigger.
type Number The type of operation. See Mixin.Constants for constants to use.
phase Number The phase of the operation. See Mixin.Constants for constants to use.
oldDoc Object The document snapshot before operations are carried out against the data.
newDoc Object The document snapshot after operations are carried out against the data.
Source:
Returns:
Type
boolean

(static) removeTrigger(id, type, phase) → {boolean}

Parameters:
Name Type Description
id String The id of the trigger to remove.
type Number The type of operation to remove the trigger from. See Mixin.Constants for constants to use.
phase Number The phase of the operation to remove the trigger from. See Mixin.Constants for constants to use.
Source:
Returns:
True if removed successfully, false if not.
Type
boolean

(static) willTrigger(type, phase) → {Boolean}

Checks if a trigger will fire based on the type and phase provided.
Parameters:
Name Type Description
type Number The type of operation. See Mixin.Constants for constants to use.
phase Number The phase of the operation. See Mixin.Constants for constants to use.
Source:
Returns:
True if the trigger will fire, false otherwise.
Type
Boolean