Class: Base

Base

new Base()

Base model that all other models will inherit from. Provides Promises/A functionality as well as publish/subscribe functionality.
Properties:
Name Type Description
$errors Object Contains details about any error states on the instance
Source:

Methods

(static) extend(properties) → {function}

Allows for model extension
Parameters:
Name Type Description
properties Object Properties to extend the new model with. Methods may call `this._super.apply(this, arguments)` to call parent model methods that are overwritten.
Source:
Returns:
New constructor
Type
function

bind(type, cb) → {Base}

Attaches a listener to an event type.
Parameters:
Name Type Description
type String The type of event to listen for
cb function The function to trigger every time the event type occurs
Source:
Returns:
`this`
Type
Base

clone() → {Base}

Method to clone the instance.
Source:
Fires:
Returns:
`new this.constructor(null, true)`
Type
Base

fail(failopt) → {Base}

Attaches fail callback to the current promise thread.
Parameters:
Name Type Attributes Description
fail Base~failCallback <optional>
Source:
Returns:
`this`
Type
Base

init(dataopt, forCloneopt) → {Base}

Initialization method. Called automatically when a new instance is instantiated.
Parameters:
Name Type Attributes Default Description
data <optional>
Initial data to populate the instance with
forClone Boolean <optional>
false Whether this instance is being created as a clone or not
Source:
Returns:
`this`
Type
Base

isFinal(idxopt) → {Boolean}

Indicates whether the instance has been finalized (resolved or rejected)
Parameters:
Name Type Attributes Default Description
idx number <optional>
this.$$cbQueueIdx Thread index to check
Source:
Returns:
Type
Boolean

notify(idxopt, dataopt) → {Base}

Triggers a progress step for the provided promise thread.
Parameters:
Name Type Attributes Default Description
idx <optional>
this.$$cbQueueIdx Promise thread to notify of progress
data <optional>
Data related to the progress step
Source:
Fires:
Returns:
`this`
Type
Base

one(type, cb) → {Base}

Attaches a one-time listener to an event type. After triggering once, the listener will automtically be unbound.
Parameters:
Name Type Description
type String The type of event to listen for
cb function The function to trigger the next time the event type occurs
Source:
Returns:
`this`
Type
Base

progress(progressopt) → {Base}

Attaches a progress callback to the current promise thread.
Parameters:
Name Type Attributes Description
progress Base~progressCallback <optional>
Source:
Returns:
`this`
Type
Base

reject(idxopt, dataopt) → {Base}

Marks the promise thread as "rejected" (unsuccessfully complete).
Parameters:
Name Type Attributes Default Description
idx <optional>
this.$$cbQueueIdx Promise thread to reject
data <optional>
Data related to the rejection
Source:
Fires:
Returns:
`this`
Type
Base

resolve(idxopt, dataopt) → {Base}

Marks the promie thread as "resolved" (successfully complete).
Parameters:
Name Type Attributes Default Description
idx <optional>
this.$$cbQueueIdx Promise thread to resolve
data <optional>
Data related to the resolution
Source:
Fires:
Returns:
`this`
Type
Base

success(successopt) → {Base}

Attaches success callback to the current promise thread.
Parameters:
Name Type Attributes Description
success Base~successCallback <optional>
Source:
Returns:
`this`
Type
Base

trigger(type, dataopt) → {Boolean}

Triggers an event of the given type, passing any listeners the data provided.
Parameters:
Name Type Attributes Description
type String The type of event to trigger
data <optional>
Object to pass into any listeners
Source:
Returns:
Returns `true` if all listeners return true, else `false`
Type
Boolean

unbind(type, listeneropt) → {Base}

Detaches either all listeners or just a single listener from an event type.
Parameters:
Name Type Attributes Description
type String The type of event to unbind
listener function <optional>
The specific listener to unbind from the event type. If not provided, all listeners bound to the event type will be removed
Source:
Returns:
`this`
Type
Base

unfinalize() → {number}

"Resets" the Promise state on the instance by incrementing the current promise thread index.
Source:
Fires:
Returns:
`idx` New promise thread index
Type
number

Type Definitions

alwaysCallback()

Always callback will be triggered when/if the current promise thread is finalized (either resolved OR rejected).
Source:

failCallback()

Fail callback will be triggered when/if the current promise thread is rejected.
Source:

progressCallback()

Progress callback will be triggered as the current promise thread passes through various states of progress.
Source:

successCallback()

Success callback will be triggered when/if the current promise thread is resolved.
Source:

Events

cloned

Event that triggers when the source model is cloned
Properties:
Name Type Description
clone Base The new instance that was created as a result of the clone
Source:

finalized

Event that triggers when the model is finalized (resolved or rejected)
Source:

notified

Event that triggers when the model is notified (progress is recorded)
Source:

rejected

Event that triggers when the model is rejected (generally when a data load fails)
Source:

resolved

Event that triggers when the model is resolved (generally when data is loaded succesfully)
Source:

unfinalized

Event that triggers when the model is unfinalized (reset back to being neither resolved nor rejected)
Source: