Home Reference Source
import ImmutableStore from '@xailabs/altx/src/ImmutableStore.js'
public class | source

ImmutableStore

Constructor Summary

Public Constructor
public

constructor(initialData: *)

Member Summary

Public Members
public

find(listName: string, filter: object): List: *

Returns a list of items that match a filter.

public
public
public
public
public

reset: *

public

state: *

Method Summary

Public Methods
public

change(prop: *, value: *)

Changes a property to a new value.

public

changeItem(filter: object, data: object)

Changes a specific item in a list within the state object.

public

init(data: *): *

public

setItemProp(id: *, key: *, value: *, listName: *): *

public

useApi(): *

Public Constructors

public constructor(initialData: *) source

Params:

NameTypeAttributeDescription
initialData *

Public Members

public find(listName: string, filter: object): List: * source

Returns a list of items that match a filter.

Return:

List

A new immutable list that only contains items that matched all key/value pairs of filter

public getIndexById: * source

public getItemById: * source

public initialData: * source

public listName: string source

public reset: * source

public state: * source

Public Methods

public change(prop: *, value: *) source

Changes a property to a new value. There are three modes of calling this function:

change('key', value) changes one property of the state object.

Params:

NameTypeAttributeDescription
prop *
value *

See:

public changeItem(filter: object, data: object) source

Changes a specific item in a list within the state object.

Params:

NameTypeAttributeDescription
filter object
filter.item object

An object that specifies key/value pairs that must be matched by list items, e.g. {id: 13}

filter.list string
  • optional

The name of the list to search in. Defaults to 'items'

data object

An object containing key/value pairs for data to be set at matched items

Throw:

*

Error if when no item could be found

public init(data: *): * source

Params:

NameTypeAttributeDescription
data *

Return:

*

public setItemProp(id: *, key: *, value: *, listName: *): * source

Params:

NameTypeAttributeDescription
id *
key *
value *
listName *

Return:

*

public useApi(): * source

Return:

*