Binding

Binding

Stores the router and closer functions of bound objects.

Members

Fields & Properties
Methods

Constructor

new Binding(object, router, closer, typeopt, clonedObject)

Parameters
Name Type Attributes Default Description
object object | function

The object that will be bound.

router function

The router function for this binding.

closer function

The closer function for this binding.

type types <optional>
Binding.types.normal

The type of binding to be used.

clonedObject object

Only set if type=clone. Object the given object is a clone of.

Members

(static, constant) types :symbol

The types of Bindings.

Properties:
Name Type Description
__proto__ symbol
normal symbol

Only allow bindings to unbound objects; throw otherwise. Afterwards the given object is bound (Binding.isBound will return true).

clone symbol

Allow any object or function as binding target. Afterwards the given object will not be changed: Unbound if it was unbound before, bound (with the same Binding) if it was bound before.

rebind symbol

Allow any object or function as binding target. Afterwards the given object is bound (Binding.isBound will return true). If the object was bound before, the old binding is overridden.

closer :function

Stores the closer function.

router :function

Stores the router function.

target :object

The object that is bound by this Binding.

type :Binding.types

The binding type that was used to create this Binding.

Methods

(static) bind(object, routernon-null, closernon-null, typeopt) → {object|function}

Binds an unbound object.

Parameters
Name Type Attributes Default Description
object object | function

The object to be bound. If the given object (strictly) equals null, a new empty object will be used as the binding target.

router function

The router function to be used for the binding.

closer function

The closer function to be used fro the binding.

type symbol <optional>
Binding.types.normal

The type of binding to be used.

Returns

The object that was given. Now bound. If null was given, the newly created empty bound object will be returned.

Type
object | function

(static) getBinding(object) → (nullable) {Binding}

Returns the Binding object of the given object if it is bound. undefined elsewise.

Parameters
Name Type Description
object object

The object that should be checked.

Returns

The binding of object.

Type
Binding

(static) isBound(object) → {boolean}

Returns whether the given object is bound (it has a Binding associated to it).

Parameters
Name Type Description
object any

The object to check. This can be any value. The method will always return false for non-objects.

Returns

true if the object is bound. false if not.

Type
boolean

(static) unbind(object) → {any}

Removes the binding of the given object.

Parameters
Name Type Description
object any

The bound object that should be unbound. If object is not bound, nothing happens.

Returns

Returns the object that was given. Now unbound.

Type
any

close(route, origin, destination)

Calls Binding#closer with a State object as its this-context.

Parameters
Name Type Description
route Array.<any>

The value for State#route

origin object

The value for State#origin

destination any

The data to close with.

route(route, origin, destination)

Calls Binding#router with a State object as its this-context.

Parameters
Name Type Description
route Array.<any>

The value for State#route

origin object

The value for State#origin

destination any

The destination to route to.