Home Reference Source
public class | source

List

Extends:

CoreItem → List

List for plain object or Item.

Constructor Summary

Public Constructor
public

constructor(defaultData: Array, opts: object)

Constructor.

Member Summary

Public Members
public get

length: *

Private Members
private
private

_data: *

Method Summary

Public Methods
public
public

add(item: Any, insertIndex: number)

Add an item.

public

addAll(items: Array, insertIndex: number)

Add items.

public

find(predictOrField: string | Function, value: *): object

Iterates each item of self, return an index of the first item predicate returns true.

public

forEach(cb: *)

public

get(index: number): *

Return an item at position.

public

indexOf(predictOrField: string | Function | Object, value: *): number

Iterates each item of self, return the first item predicate returns true.

public

itemClass(item: object): Class<View>

If you dynamically change wrapping item class according to the item, override this method.

public

remove(itemOrIndex: object | number)

Remove an item (specified by index).

public

removeAll(opts: Object)

Remove all items.

public

Remove last item.

public

reset(newValues: Array)

replace all items

public

some(cb: *): *

public

update(item: Any, index: number)

Update an item at index.

Private Methods
private

_wrapItem(item: *): *

Wrap an item by Item class

Inherited Summary

From class Core
public

listened(nameOrObj: string | Object, handler: Function)

Add handler or listener for saying message

public

say(name: string, ctx: *)

Cast a message to the listeners

public

Unescape HTML

public

Remove handler or listener

private

_callR(args: *, target: *, method: *, methodOwner: *)

private

_isFn(f: *): *

private

_isStr(v: *): *

private

_listened(name: *, handler: *)

private

_privates(): {"_F_obs": *}

Return non-enumerable attribute definitions.

private

_say(targetName: *, name: *, ctx: *)

From class Item
public

[field]: *

public

add(field: string, value: Any)

Add value to field-value.

public

Destroy me.

public

toggle(field: string)

Toggle boolean field-value

public

update(pairs: Object)

Update the pairs of field-value.

private

_updateField(field: string, value: Any)

Update field with value.

Public Constructors

public constructor(defaultData: Array, opts: object) source

Constructor.

Override:

Item#constructor

Params:

NameTypeAttributeDescription
defaultData Array
  • optional

default data array

opts object
  • optional

options

opts.wrapItem boolean | Class<Item>
  • optional

Whether wrapping Item or not, or the sub class of Item.

Public Members

public get length: * source

Private Members

private _F_itemClass: * source

private _data: * source

Public Methods

public [Symbol.iterator](): * source

Return:

*

public add(item: Any, insertIndex: number) source

Add an item.

Override:

Item#add

Params:

NameTypeAttributeDescription
item Any

item

insertIndex number
  • optional

optional insert position, add last if not defined

public addAll(items: Array, insertIndex: number) source

Add items.

Params:

NameTypeAttributeDescription
items Array

adding items

insertIndex number
  • optional

insert position

public find(predictOrField: string | Function, value: *): object source

Iterates each item of self, return an index of the first item predicate returns true.

Params:

NameTypeAttributeDescription
predictOrField string | Function

predicate function or target field

value *
  • optional

finding value for target field

Return:

object

matched first item or undefined

public forEach(cb: *) source

Params:

NameTypeAttributeDescription
cb *

public get(index: number): * source

Return an item at position.

Params:

NameTypeAttributeDescription
index number

item position.

Return:

*

item specified by index.

public indexOf(predictOrField: string | Function | Object, value: *): number source

Iterates each item of self, return the first item predicate returns true.

Params:

NameTypeAttributeDescription
predictOrField string | Function | Object

predicate function or target field, target object

value *
  • optional

finding value for target field

Return:

number

matched first item index or -1 if not found

public itemClass(item: object): Class<View> source

If you dynamically change wrapping item class according to the item, override this method.

Params:

NameTypeAttributeDescription
item object

an item

Return:

Class<View>

public remove(itemOrIndex: object | number) source

Remove an item (specified by index).

Params:

NameTypeAttributeDescription
itemOrIndex object | number

target item or the position.

public removeAll(opts: Object) source

Remove all items.

Params:

NameTypeAttributeDescription
opts Object

if opts.reverse is true, removing from last to first.

public removeLast() source

Remove last item.

public reset(newValues: Array) source

replace all items

Params:

NameTypeAttributeDescription
newValues Array
  • optional

new values or default empty array

public some(cb: *): * source

Params:

NameTypeAttributeDescription
cb *

Return:

*

public update(item: Any, index: number) source

Update an item at index.

Override:

Item#update

Params:

NameTypeAttributeDescription
item Any

item

index number

target index

Private Methods

private _wrapItem(item: *): * source

Wrap an item by Item class

Params:

NameTypeAttributeDescription
item *

Return:

*