Api

Api

Represents an API node.

Members

Fields & Properties
Methods

Constructor

new Api(pObject, pRoute, pOriginopt)

Parameters
Name Type Attributes Default Description
pObject object | Promise

A bound object this Api should be exposing. This may also be a Promise that resolves to a bound object.

pRoute Array.<any>

The stack of routes that led to this Api pointer.

pOrigin object <optional>
{}

An object to use as the origin of this Api.

Members

object :Promise

Resolves to the exposed object this Api is pointing to.

proxified :Proxy

A proxy that returns this.route(A).proxified when property A is accessed and this.close(B) when called with parameter B. then and catch however are directly passed through.

Methods

catch(fail) → {Promise}

Shorthand for this.close().catch().

Parameters
Name Type Description
fail function

The fail function.

Returns

Rejects if this.close() rejects.

Type
Promise

close(dataopt) → {Promise}

Closes the Api with the closing function of its exposed object.

Parameters
Name Type Attributes Description
data any <optional>

The data to close with.

Returns

A promise that resolves to the return value of the closing function.

Type
Promise

origin(value) → {Api}

Setter for the origin of an Api.

Parameters
Name Type Description
value object

The origin object for the new Api node.

Returns

Returns a new Api with the given origin, that points at the same exposed object.

Type
Api

route(…destination) → {Api}

Routes the Api according to its exposed objects routing function.

Parameters
Name Type Attributes Description
destination any <repeatable>

The destination to route to. Multiple destinations are handled like a chained Api#route call.

Returns

A new Api for the object the routing function returned.

Type
Api

then(success, fail) → {Promise}

Shorthand for this.close().then().

Parameters
Name Type Description
success function

The success function.

fail function

The fail function.

Returns

Result of this.close().

Type
Promise