Global

Methods

isObservable(value) → {boolean}

Parameters:
Name Type Description
value *
Source:
Returns:
Type
boolean

observable(initialValue) → {Observable}

Get a new Observable instance intialized with the given value.

Parameters:
Name Type Description
initialValue *
Source:
Returns:
Type
Observable
Example
const observableOne = observable(1);
const observableTwo = observable(2);

onChange(fn, …observables) → {Subscription}

Call the supplied function when any of the observables change. The function will be called with the current values of the observables.

Parameters:
Name Type Attributes Description
fn MultiObserver
observables Observable <repeatable>
Source:
Returns:
Type
Subscription
Example
const obs1 = observable(1);
const obs2 = observable(2);
const obs3 = observable(3);
onChange((a, b, c) => console.log(a + b + c), obs1, obs2, obs3);
obs1(2);  // logs 7
obs2(3);  // logs 8
obs3(4);  // logs 9

Type Definitions

MultiObserver(values)

This callback will be called with the current values of all the observables.

Parameters:
Name Type Description
values Array.<any>
Source:
Example
const obs1 = observable(1);
const obs2 = observable(2);
const obs3 = observable(3);
const fn = (a, b, c) => console.log(`${a}-${b}-${c}`); // This is the MultiObserver
onChange(fn, obs1, obs2, obs3);
obs1(2);  // logs 2-2-3
obs2(3);  // logs 2-3-3
obs3(4);  // logs 2-3-4

NotifyFunction(newValue, oldValue)

Calls all observers in sequence of subscription with new and old values.

Parameters:
Name Type Description
newValue *
oldValue *
Source:

ObservableValueCalculator(observableValues) → {*}

Parameters:
Name Type Description
observableValues Array.<any>
Source:
Returns:
Type
*

Observer(newValue, oldValue)

Parameters:
Name Type Description
newValue *
oldValue *
Source:

SubscribeFunction(observer) → {Subscription}

Parameters:
Name Type Description
observer Observer
Source:
Returns:
Type
Subscription