Reference Source
public class | source

AlertModel

Extends:

* → AlertModel

Class for the alert model to be used by the alert Presenter

Constructor Summary

Public Constructor
public

Creates an instance of AlertModel.

Member Summary

Public Members
public
Private Members
private
private
private

_data: {"data": *}

Method Summary

Public Methods
public

get(): Object

Get method for presenters to get data.

public

Return the number of notifications.

public

Moves the bookmarked data to the front of the list.

public

Recalculates the 'timeago' property of the object, based on the milliseconds.

public

setCallback(callback: Function)

Set the model's callback to a new callback. This callback can be used anywhere and is usually passed in from a presenter.

public

Toggle the database listener off and then on again to get the data again.

public

update(newData: Object)

Update method for presenters to update the model's data.

Private Methods
private

_defaultCallback(message: *)

Default callback

private

_insertDataOnRead(databaseData: Object)

Insert data into the data object when data has changed from the database

private

Register an 'on' read from the database, supplying the callback when the database has changed.

Public Constructors

public constructor() source

Creates an instance of AlertModel. Initializes , creates an observerlist, and registers an on read from the database.

Public Members

public listener: * source

Private Members

private _activeBookmarks: *[] source

private _callback: * source

private _data: {"data": *} source

Public Methods

public get(): Object source

Get method for presenters to get data.

Return:

Object

data stored in the model

public getNotificationsCount(): Number source

Return the number of notifications.

Return:

Number

The number of notifications

public moveTimeDataToFront() source

Moves the bookmarked data to the front of the list.

public recalculateTimeAgo() source

Recalculates the 'timeago' property of the object, based on the milliseconds.

public setCallback(callback: Function) source

Set the model's callback to a new callback. This callback can be used anywhere and is usually passed in from a presenter.

Params:

NameTypeAttributeDescription
callback Function

A callback to run when certain code is executed

public toggleListeners() source

Toggle the database listener off and then on again to get the data again. TODO : Better method to do this?

public update(newData: Object) source

Update method for presenters to update the model's data.

Params:

NameTypeAttributeDescription
newData Object

New data to add

Private Methods

private _defaultCallback(message: *) source

Default callback

Params:

NameTypeAttributeDescription
message *

private _insertDataOnRead(databaseData: Object) source

Insert data into the data object when data has changed from the database

Params:

NameTypeAttributeDescription
databaseData Object

Each data item is an object within the overall object

private _registerDBReadListener() source

Register an 'on' read from the database, supplying the callback when the database has changed.