Options
Menu

Class RealTimeBoolean

A distributed boolean. This wraps a native javascript boolean primitive.

See RealTimeBooleanEvents for the events that can be emitted on remote changes to this object.

Common use cases are documented in the developer guide.

Hierarchy

Implements

Index

Properties

Events

Events: RealTimeBooleanEvents = ObservableBooleanEventConstants

A mapping of the events this array could emit to each event's unique name. Use this to refer an event name, e.g.

rtBoolean.on(RealTimeBoolean.Events.VALUE, function listener(e) {
  // ...
})

Methods

addListener

events

  • Provides the events emitted by this object as an Observable stream.

    example
    
    eventEmitter.events()
      .filter(e => e.name === "myevent")
      .subscribe(e => console.log(e));
    

    Returns Observable<IConvergenceEvent>

    An Observable stream of all events emitted by this object.

id

  • id(): string
  • Each node within a RealTimeModel has a system-generated ID that is unique within this model's contents.

    Returns string

    a unique (to the model) ID for this element

isAttached

  • isAttached(): boolean

isDetached

  • isDetached(): boolean

model

off

on

once

parent

path

reference

  • Returns the remote ModelReference created by the given sessionId with the unique name key, or undefined if no such reference exists.

    See Remote References in the developer guide.

    Parameters

    • sessionId: string

      The session ID that created the reference

    • key: string

      the reference's unique key

    Returns ModelReference

references

  • Returns any remote references that match the given filter. You can provide a single key which could return references from multiple users, sessionId which would return all of a particular user session's references, or both, which is really just the same as using the reference method.

    Parameters

    • referenceFilter: ReferenceFilter

      an object containing either a sessionId, key, or both

    Returns ModelReference[]

    An array of remote ModelReferences, or an empty array if there were no matches.

relativePath

  • This returns the PathElement representing this element's location relevant to its parent. For example, given a model with contents

    {
      obj: {
        with: 1,
        stuff: ['a', 'string']
      }
    }
    
    let rtNumber = rtModel.elementAt(['obj', 'with']);
    rtNumber.value() // 1
    rtNumber.relativePath() // 'with'
    
    let rtString = rtModel.elementAt(['obj', 'stuff', 0]);
    rtString.value() // 'a'
    rtString.relativePath() // 0
    

    Returns PathElement

    a PathElement representing this node's location relative to its parent, or null if it has no parent.

removeAllListeners

removeFromParent

  • removeFromParent(): void
  • A convenience function to delete this element. Throws an error if this is the root object in a model.

    Returns void

removeListener

removeListeners

toJSON

  • toJSON(): any

type

  • type(): string

value

  • value(): boolean
  • value(value: boolean): void