Reference Source
public class | source

Model

Base class for all models

Member Summary

Public Members
public
public

observers: *[]

Private Members
private

_deepCopy: List: *

Returns a deep copy of the array by reassigning the values.

Method Summary

Public Methods
public

force()

Force a toggle of the database listeners by the children.

public

subscribe(observer: Class, force: Boolean)

Subscribes to the event stream.

public

Toggle the database listeners from on to off.

public

unsubscribe(observer: Class)

Unsubscribe from the event stream.

Private Methods
private

Creates an event stream (Subject/Observable) for presenters to subscribe to.

private
this method was deprecated. Use _createEventStream instead. This function is only used because currently all classes call it
private

_notifyAll(message: Object)

Notify all observers with a message.

Public Members

public eventStream: * source

public observers: *[] source

Private Members

private _deepCopy: List: * source

Returns a deep copy of the array by reassigning the values. This is to make sure we can clear the data.

Return:

List

A list to copy

Public Methods

public force() source

Force a toggle of the database listeners by the children.

public subscribe(observer: Class, force: Boolean) source

Subscribes to the event stream.

Params:

NameTypeAttributeDescription
observer Class

A class that will observe the event stream. Must implement onUpdated

force Boolean

Force the model to retrigger their listeners by toggling them off and on

public toggleListeners() source

Toggle the database listeners from on to off. Must be defined by children to take effect.

public unsubscribe(observer: Class) source

Unsubscribe from the event stream.

Params:

NameTypeAttributeDescription
observer Class

A class that is subscribed to be unsubscribed.

Private Methods

private _createEventStream() source

Creates an event stream (Subject/Observable) for presenters to subscribe to.

private _createObserverList() source

this method was deprecated. Use _createEventStream instead. This function is only used because currently all classes call it

private _notifyAll(message: Object) source

Notify all observers with a message.

Params:

NameTypeAttributeDescription
message Object

A message to send to the observers.