Home Reference Source
import {PrioritisedObject} from 'arva-js/data/PrioritisedObject.js'
public class | source

PrioritisedObject

Extends:

eventemitter3~EventEmitter → PrioritisedObject

Direct Subclass:

Model

Indirect Subclass:

LocalModel

Constructor Summary

Public Constructor
public

constructor(dataSource: DataSource, dataSnapshot: Snapshot): PrioritisedObject

Member Summary

Public Members
public get
public get

id: *

public set

id: *

public get

Priority (positioning) of the object in the dataSource

public set

Method Summary

Public Methods
public

Disables pushes of local changes to the dataSource, and stops event emits that refer to the model's data.

public

Enables pushes of local changes to the dataSource, and enables event emits that refer to the model's data. The change listener is active by default, so you'll only need to call this method if you've previously called disableChangeListener().

public

off(event: String, handler: Function, context: Object): void

Removes subscription to events emitted by this PrioritisedArray.

public

on(event: String, handler: Function, context: Object): void

Subscribes to events emitted by this PrioritisedArray.

public

once(event: String, handler: Function, context: Object): void

Subscribes to the given event type exactly once; it automatically unsubscribes after the first time it is triggered.

public

remove(): void

Deletes the current object from the dataSource, and clears itself to free memory.

public

transaction(method: Function): void

Allows multiple modifications to be made to the model without triggering dataSource pushes and event emits for each change.

Public Constructors

public constructor(dataSource: DataSource, dataSnapshot: Snapshot): PrioritisedObject source

Params:

NameTypeAttributeDescription
dataSource DataSource

DataSource to construct this PrioritisedObject with.

dataSnapshot Snapshot

Optional: dataSnapshot already containing model data, so we can skip subscribing to the full data on the dataSource.

Return:

PrioritisedObject

PrioritisedObject instance.

Public Members

public get dataSource: * source

public get id: * source

public set id: * source

public get priority: * source

Priority (positioning) of the object in the dataSource

public set priority: * source

Public Methods

public disableChangeListener(): void source

Disables pushes of local changes to the dataSource, and stops event emits that refer to the model's data.

Return:

void

public enableChangeListener(): void source

Enables pushes of local changes to the dataSource, and enables event emits that refer to the model's data. The change listener is active by default, so you'll only need to call this method if you've previously called disableChangeListener().

Return:

void

public off(event: String, handler: Function, context: Object): void source

Removes subscription to events emitted by this PrioritisedArray. If no handler or context is given, all handlers for the given event are removed. If no parameters are given at all, all event types will have their handlers removed.

Params:

NameTypeAttributeDescription
event String

One of the following Event Types: 'value', 'child_changed', 'child_moved', 'child_removed'.

handler Function

Function to remove from event callbacks.

context Object

Object to bind the given callback function to.

Return:

void

public on(event: String, handler: Function, context: Object): void source

Subscribes to events emitted by this PrioritisedArray.

Params:

NameTypeAttributeDescription
event String

One of the following Event Types: 'value', 'child_changed', 'child_moved', 'child_removed'.

handler Function

Function that is called when the given event type is emitted.

context Object

Optional: context of 'this' inside the handler function when it is called.

Return:

void

public once(event: String, handler: Function, context: Object): void source

Subscribes to the given event type exactly once; it automatically unsubscribes after the first time it is triggered.

Params:

NameTypeAttributeDescription
event String

One of the following Event Types: 'value', 'child_changed', 'child_moved', 'child_removed'.

handler Function

Function that is called when the given event type is emitted.

context Object

Optional: context of 'this' inside the handler function when it is called.

Return:

void

public remove(): void source

Deletes the current object from the dataSource, and clears itself to free memory.

Return:

void

public transaction(method: Function): void source

Allows multiple modifications to be made to the model without triggering dataSource pushes and event emits for each change. Triggers a push to the dataSource after executing the given method. This push should then emit an event notifying subscribers of any changes.

Params:

NameTypeAttributeDescription
method Function

Function in which the model can be modified.

Return:

void