Home Reference Source
import ReadyBond from './packages/oo7/src/readyBond.js'
public class | source

ReadyBond

Extends:

Bond → ReadyBond

Derivative Bond representing the readiness of another Bond.

Constructor Summary

Public Constructor
public

Member Summary

Private Members
private
private

_poll: *

private

Method Summary

Public Methods
public
public

Inherited Summary

From class Bond
public static

all(list: array, resolveDepth: number): *

Create a new Bond which represents the array of many objects' representative values.

This object will be ready if and only if all objects in list are themselves ready.

public static

instanceOf(b: *): *

Duck-typed alternative to instanceof Bond, when multiple instantiations of Bond may be available.

public static

mapAll(list: array, f: function, resolveDepth: number, outResolveDepth: number): *

Create a new Bond which represents a functional transformation of many objects' representative values.

public static

promise(list: array): Promise

Create a Promise which represents one or more Bonds.

private static

_fromSymbol(name: *): *

private static

_knowSymbol(name: *): *

private
private
private
private

_notifies: {}

private

_parse: *

private
private
private
private
private

_thens: *[]

private
private
private

_uuid: *

private

_value: *

public

changed(v: *)

Makes the object ready and sets its current value.

public

default(defaultValue: Symbol): *

Provide a Bond which represents the same as this object except that it takes a particular value when this would be unready.

public

defaultTo(x: *): *

Alters this object so that it is always ready.

public

done(f: Bond~thenCallback): *

Register a function to be called when this object becomes done.

public

drop()

Unregister a single dependency for this object.

public

Determine if there is a definite value that this object represents at present.

public

latched(defaultValue: Symbol): *

Provide a derivative Bond which represents the same as this object except that before it is ready it evaluates to a given default value and after it becomes ready for the first time it stays fixed to that value indefinitely.

public

log(): *

Logs the current value to the console.

public

map(transform: function, outResolveDepth: number, cache: *, latched: *, mayBeNull: *): *

Make a new Bond which is the functional transformation of this object.

public

mapEach(transform: function): *

Create a new Bond which represents this object's array value with its elements transformed by a function.

public

Maps the represented value to a string.

public

notReady(): *

Convenience function for the logical negation of Bond#ready.

public

notify(f: Bond~notifyCallback): Symbol

Register a function to be called when the value or the readiness changes.

public

ready(): *

Provide a Bond which represents whether this object itself represents a particular value.

public

reduce(accum: function, init: *): Bond

Lazily transforms the contents of this object's value when it is an array.

This operates on a Bond which should represent an array. It transforms this into a value based on a number of elements at the beginning of that array using a recursive reduce algorithm.

The reduce algorithm works around an accumulator model. It begins with the init value, and incremenetally accumulates elements from the array by changing its value to one returned from the accum function, when passed the current accumulator and the next value from the array. The accum function may return a Bond, in which case it will be resolved (using Bond#then) and that value used.

The accum function returns a value (or a Bond which resolves to a value) of an array with exactly two elements; the first is the new value for the accumulator. The second is a boolean early exit flag.

Accumulation will continue until either there are no more elements in the array to be processed, or until the early exit flag is true, which ever happens first.

public

reset()

Resets the state of this Bond into being not ready.

public

sub(name: string | number, outResolveDepth: number): *

Create a new Bond which represents this object's value when subscripted.

public

Provides a transparently subscriptable version of this object.

public

then(f: Bond~thenCallback): *

Register a function to be called when this object becomes ready.

public

tie(f: Bond~tieCallback): Symbol

Register a function to be called when the value changes.

public

toString(): *

public

trigger(v: *)

Makes the object ready and sets its current value.

public

Unregister a function previously registered with Bond#notify.

public

untie(id: Symbol)

Unregister a function previously registered with Bond#tie.

public

use(): *

Register a single dependency for this object.

public

xform(transform: function, outResolveDepth: number, cache: *, latched: *, mayBeNull: *): *

Just like map, except that it defaults to no latching and mayBeNull.

protected

Uninitialise the object.

protected

Initialise the object.

protected

Returns whether the object is currently in a terminal state.

Public Constructors

public constructor() source

Constructs a new Bond object whose value is not ready.

Override:

Bond#constructor

Private Members

private _notifyId: * source

private _poll: * source

private _targetBond: * source

Public Methods

public finalise() source

Uninitialise the object.

Will be called at most once after an accompanying Bond#initialise and should close/finalise/drop any resources that are required for the sub-class to maintain its value.

Override:

Bond#finalise

public initialise() source

Initialise the object.

Will be called at most once before an accompanying Bond#finalise and should initialise/open/create any resources that are required for the sub-class to maintain its value.

Override:

Bond#initialise