Home Reference Source
import RemoteValue from 'remote-context/lib/RemoteValue.js'
public class | source

RemoteValue

Extends:

events~EventEmitter → RemoteValue

Remote value representation locally.

Example:

import { RemoteValue } from 'remote-context';

const proxy = new RemoteValue(remoteSession, reference, value);

Static Method Summary

Static Public Methods
public static

Check if the give value is a proxy of remote value.

public static

observe(proxy: RemoteValueProxy, onNext: function | null, onError: function | null, onComplete: function | null): function(): boolean}

Observe for any change on the given remote value proxy.

public static

Resolve the given value.

public static

Get the remote value instance of the given proxy.

public static

revoke(proxy: *): void

If the given value is a RemoteValueProxy, revoke the value proxy.

Constructor Summary

Public Constructor
public

constructor(session: RemoteSession, reference: Reference, value: *): RemoteValueProxy

Create a RemoteValue class and a proxy to the given value.

Member Summary

Public Members
public
public
public get

proxy: *

public get

target: *

Method Summary

Public Methods
public

defineProperty(property: *, descriptor: *): boolean

public

deleteProperty(property: *): boolean

public
public

reject(error: *)

public

revoke()

public

setPrototypeOf(prototype: *): boolean

Static Public Methods

public static isRemoteValue(proxy: RemoteValueProxy | *): boolean source

Check if the give value is a proxy of remote value.

Params:

NameTypeAttributeDescription
proxy RemoteValueProxy | *

The given value

Return:

boolean

public static observe(proxy: RemoteValueProxy, onNext: function | null, onError: function | null, onComplete: function | null): function(): boolean} source

Observe for any change on the given remote value proxy.

Params:

NameTypeAttributeDescription
proxy RemoteValueProxy

The given remove value proxy

onNext function | null

Called on every change to the given value with the RemoteValueProxy as the first argument

onError function | null

Called on every error occurred on the given value with an error as first argument

onComplete function | null

Called when the given value revoked with no arguments

Return:

function(): boolean}

An subscription object with unsubscribe method to stop observer events from calling and a closed property.

See:

  • https://github.com/tc39/proposal-observable

public static resolve(value: RemoteValueProxy | *): Promise source

Resolve the given value. Reject the value if it's a RemoteValueProxy and an uncaught error accord while using the value (ie. assign property to the value failed). Otherwise, resolve it.

Params:

NameTypeAttributeDescription
value RemoteValueProxy | *

The given value

Return:

Promise

public static reveal(proxy: RemoteValueProxy): RemoteValue source

Get the remote value instance of the given proxy.

Params:

NameTypeAttributeDescription
proxy RemoteValueProxy

The given proxy

Return:

RemoteValue

Throw:

ReferenceError

If the given value is not a RemoteValueProxy.

public static revoke(proxy: *): void source

If the given value is a RemoteValueProxy, revoke the value proxy. Otherwise, do nothing.

Params:

NameTypeAttributeDescription
proxy *

The given value

Return:

void

Public Constructors

public constructor(session: RemoteSession, reference: Reference, value: *): RemoteValueProxy source

Create a RemoteValue class and a proxy to the given value.

Params:

NameTypeAttributeDescription
session RemoteSession

The current value remote session

reference Reference

he value reference for further updates to the remote peer

value *

The given value

Return:

RemoteValueProxy

A proxy to the given value

Public Members

public [kError]: * source

public [kProxyData]: * source

public get proxy: * source

public get target: * source

Public Methods

public defineProperty(property: *, descriptor: *): boolean source

Params:

NameTypeAttributeDescription
property *
descriptor *

Return:

boolean

public deleteProperty(property: *): boolean source

Params:

NameTypeAttributeDescription
property *

Return:

boolean

public preventExtensions(): boolean source

Return:

boolean

public reject(error: *) source

Params:

NameTypeAttributeDescription
error *

public revoke() source

public setPrototypeOf(prototype: *): boolean source

Params:

NameTypeAttributeDescription
prototype *

Return:

boolean