Class: observable

html. observable

new observable(data)

Observable data, implementation of observer pattern

Parameters:
Name Type Description
data Object

Data to be observed

See:

Members

_computedFn

Save a reference to the function of computed value

_newData

Get and set underlying without side effect

_oldData

Old data of the observable object, internal use

bindingNodes

Save a list of input/textarea element. This is helpful for validation and error handling

delayTime

Delay time

dependencies

All references to observable objects what depend on this

isValid

Is valid state, default be null, not validated state
NOTE: Null is different from valid and invalid state

rules

All validation rules

subscribers

Subscribers that listen to data changes

Methods

delay(time)

Set delay time of notifying changes

Parameters:
Name Type Description
time Number

Delay time (miliseconds)

notify()

Notify changes to subscribers

setDependency(dependency)

Set a dependency

Parameters:
Name Type Description
dependency html.observable

Dependency of this data

subscribe(observer)

Subscribe change to observable data. Whenever the underlaying data changes, it trigger all subscribed functions

Parameters:
Name Type Description
observer function

Observer

validate()

Validate data against validators

validators(rule)

Register validation rule for html.observable

Parameters:
Name Type Description
rule function

Validation rule function