new observableArray(arr)
Observable Array class
Parameters:
Name | Type | Description |
---|---|---|
arr |
Array | Array data to observe |
Extends
Members
-
_computedFn
-
Save a reference to the function of computed value
- Inherited From:
-
_newData
-
Get and set underlying without side effect
- Inherited From:
-
_oldData
-
Old data of the observable object, internal use
- Inherited From:
-
bindingNodes
-
Save a list of input/textarea element. This is helpful for validation and error handling
- Inherited From:
-
delayTime
-
Delay time
- Inherited From:
-
dependencies
-
All references to observable objects what depend on this
- Inherited From:
-
isValid
-
Is valid state, default be null, not validated state
NOTE: Null is different from valid and invalid state- Inherited From:
-
rules
-
All validation rules
- Inherited From:
-
subscribers
-
Subscribers that listen to data changes
- Inherited From:
Methods
-
add(item, index)
-
Add an item into an observable array
Parameters:
Name Type Description item
Object Item to add
index
Number Index to add
-
delay(time)
-
Set delay time of notifying changes
Parameters:
Name Type Description time
Number Delay time (miliseconds)
- Inherited From:
-
notify(listItem, item [, index] [, action])
-
Notify changes to subscribers
Parameters:
Name Type Argument Default Description listItem
Array | Object Newest data underlying observable
item
Object Item changed
index
Number <optional>
null Index of item changed
action
String <optional>
"render" Action to notify to subscriber
- Overrides:
-
push(item)
-
Push an item into an observable array
Parameters:
Name Type Description item
Object Item to add
-
remove(item)
-
Remove an item from the observable array
Parameters:
Name Type Description item
Object Item to be removed
-
removeAt(index)
-
Remove an item from the list
Parameters:
Name Type Description index
Number Index of removed item
-
setDependency(dependency)
-
Set a dependency
Parameters:
Name Type Description dependency
html.observable Dependency of this data
- Inherited From:
-
subscribe(observer)
-
Subscribe change to observable data. Whenever the underlaying data changes, it trigger all subscribed functions
Parameters:
Name Type Description observer
function Observer
- Inherited From:
-
update(item, index)
-
Update an item of the list
Parameters:
Name Type Description item
Object New item to update
index
Number Index of the item
-
validate()
-
Validate data against validators
- Inherited From:
-
validators(rule)
-
Register validation rule for html.observable
Parameters:
Name Type Description rule
function Validation rule function
- Inherited From: