Context
Extends:
Direct Subclass:
Example:
import { Context } from 'remote-context';
const context = new Context(envContext);
Static Method Summary
Static Public Methods | ||
public static |
isReferable(value: *): boolean Check if the given value is unique per this environment. |
Constructor Summary
Public Constructor | ||
public |
constructor(envContext: EnvContext, context: object, opts: object) Create a new virtual context on the given environment. |
Method Summary
Public Methods | ||
public |
clear() |
|
public |
fetch(reference: Reference): LocalPromise Fetch a local reference and return a local promise. |
|
public |
release(value: *): * |
|
public |
remote(stream: Stream, opts: object): RemoteContext Get the remote context of this context. |
|
public |
resolve(value: *): LocalPromise Resolve a local value and return a local promise to that value. |
|
public |
set(reference: *, value: *): * |
Inherited Summary
From class ReferenceContext | ||
public static |
isValidReference(reference: *): boolean Check if the given reference is valid. |
|
public get |
The the number of values in this context including it's parents. |
|
public get |
The the number of values in this context (excluding the parents). |
|
public get |
The the number of keys in this context (excluding the parents). |
|
public get |
Get the parent context. |
|
public get |
The the number of keys in this context including it's parents. |
|
public |
Assign a new reference for the given value or return it's current reference. |
|
public |
clear(): void Clear and release all the values on this context. |
|
public |
Create a closure context for this context. |
|
public |
copyFrom(context: ReferenceContext | Map | Array | object): ReferenceContext Copy from other context it's references and values |
|
public |
Remove the given reference from this context. |
|
public |
Check if this context or one of it's parents has the given value. |
|
public |
forEach(callback: function, thisArg: *): ReferenceContext Iterate over the context own values. |
|
public |
Generate a reference for the |
|
public |
Get the reference value on this context or it's parents. |
|
public |
Check if this context or it's parents has the given reference. |
|
public |
hasOwnReference(reference: Reference): boolean Check if this context only (and not the parents) has the given reference. |
|
public |
Get the reference of the given value in this context or one of it's parents. Return undefined if the value not exists. |
|
public |
Check if this context only (excluding the parents) has the given value. |
|
public |
Release a value from this context and remove any reference for this value. |
|
public |
set(reference: Reference, value: *): ReferenceContext Set a reference for the given value. |
|
public |
Get the instance constructor name. |
From class AssignableContext | ||
public |
generateReference(): * |
Static Public Methods
Public Constructors
public constructor(envContext: EnvContext, context: object, opts: object) source
Create a new virtual context on the given environment.
Override:
AssignableContext#constructorParams:
Name | Type | Attribute | Description |
envContext | EnvContext | The given environment |
|
context | object | The context to create |
|
opts | object | Options for AssignableContext.constructor |
Public Methods
public clear() source
Clear and release all the values on this context.
Override:
ReferenceContext#clearpublic fetch(reference: Reference): LocalPromise source
Fetch a local reference and return a local promise.
Params:
Name | Type | Attribute | Description |
reference | Reference | The local reference to fetch |
public release(value: *): * source
Release a value from this context and remove any reference for this value. If the value exists on the parent context, this method will do nothing.
Override:
ReferenceContext#releaseParams:
Name | Type | Attribute | Description |
value | * |
Return:
* |
public remote(stream: Stream, opts: object): RemoteContext source
Get the remote context of this context. A single context can be served to multiple peers, each peer will get a separate copy of the context.
Params:
Name | Type | Attribute | Description |
stream | Stream | a duplex stream to the remote peer context |
|
opts | object |
|
Options to RemoteSession |
public resolve(value: *): LocalPromise source
Resolve a local value and return a local promise to that value.
Params:
Name | Type | Attribute | Description |
value | * | The local value to resolve |
public set(reference: *, value: *): * source
Set a reference for the given value.
Override:
ReferenceContext#setParams:
Name | Type | Attribute | Description |
reference | * | ||
value | * |
Return:
* |