Home Reference Source
import DataCollection from 'potassium-es/src/DataCollection.js'
public class | source

DataCollection

Extends:

EventHandlerDataObject → DataCollection

DataCollection represents an ordered list of DataModel instances

Constructor Summary

Public Constructor
public

constructor(data: Object[], options: Object)

Member Summary

Public Members
public
public get

length: *

Method Summary

Public Methods
public
public

add(dataObject: *)

public

addBatch(dataObjects: *)

public

at(index: *): *

public
public

create(data: *, options: {}): *

public

firstByField(fieldName: *, value: *): *

public

generateDataObject(data: *): *

public

indexOf(dataObject: *): *

public

keepSortedByField(fieldName: *, comparator: *)

public

remove(dataObject: *)

public

reset(data: *)

public

sort(comparator: *)

public

sortByAttribute(attributeName: *, comparator: *)

Inherited Summary

From class EventHandler
public get

listeners: EventListener[]: *

public

addListener(callback: function(eventName: string, eventSource: EventHandler), eventName: Object | Symbol, once: bool)

public
public

removeListener(callback: *, eventName: undefined)

public

trigger(eventName: *, params: ...*)

Send an event to listeners

From class DataObject
public static

fetchAll(dataObjects: ...*): *

Fetch each DataObject and then wait for them all to return Note: this resolves when the fetches complete, regardless of whether they succeed or fail.

public get

fetchOptions: {"credentials": string}

public get

isNew: bool

public get
public
public

options: *

public
public

delete(): *

public

equals(obj: *): *

public

fetch(): *

public

onFirstReset(func: *)

public

parse(data: *): *

public

reset(data: {})

Clear out old data and set it to data, should trigger a 'reset' event

public

save(): *

Public Constructors

public constructor(data: Object[], options: Object) source

Override:

DataObject#constructor

Params:

NameTypeAttributeDescription
data Object[]
  • optional
  • default: null
options Object
  • optional
  • default: {}
options.dataObject class
  • optional

the DataObject extending class to use to wrap each data item in this collection

Public Members

public dataObjects: *[] source

public get length: * source

Public Methods

public * [Symbol.iterator]() source

public add(dataObject: *) source

Params:

NameTypeAttributeDescription
dataObject *

public addBatch(dataObjects: *) source

Params:

NameTypeAttributeDescription
dataObjects *

public at(index: *): * source

Params:

NameTypeAttributeDescription
index *

Return:

*

public cleanup() source

Override:

DataObject#cleanup

public create(data: *, options: {}): * source

Params:

NameTypeAttributeDescription
data *
options {}
  • optional
  • default: {}

Return:

*

public firstByField(fieldName: *, value: *): * source

Params:

NameTypeAttributeDescription
fieldName *
value *

Return:

*

public generateDataObject(data: *): * source

Params:

NameTypeAttributeDescription
data *

Return:

*

public indexOf(dataObject: *): * source

Params:

NameTypeAttributeDescription
dataObject *

Return:

*

public keepSortedByField(fieldName: *, comparator: *) source

Params:

NameTypeAttributeDescription
fieldName *
comparator *
  • optional

public remove(dataObject: *) source

Params:

NameTypeAttributeDescription
dataObject *

public reset(data: *) source

Clear out old data and set it to data, should trigger a 'reset' event

Override:

DataObject#reset

Params:

NameTypeAttributeDescription
data *

public sort(comparator: *) source

Params:

NameTypeAttributeDescription
comparator *
  • optional

public sortByAttribute(attributeName: *, comparator: *) source

Params:

NameTypeAttributeDescription
attributeName *
comparator *
  • optional