Options
Menu

Class ModelReference<V>

The base class for all references, which are essentially pointers to elements and data within a RealTimeModel. They are typically used to implement transient UX constructs such as text selections and cursors.

See ModelReferenceEvents for all of the events that could be emitted from instances of this class.

Type parameters

  • V = any

Hierarchy

Index

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.

isDisposed

  • isDisposed(): boolean
  • Returns true if this reference has already been disposed (cleaned up).

    Returns boolean

isLocal

  • isLocal(): boolean
  • Returns true if this reference was created locally.

    Returns boolean

isSet

  • isSet(): boolean
  • Returns true if a value is currenly set on the reference.

    Returns boolean

key

  • key(): string
  • Returns the unique key corresponding to this reference.

    Returns string

off

on

once

  • Adds a single shot event listener for the specified event. The listener will be called the first time the specified event is fired after the event registration occurs, after which the registration will be removed and no further events will be passed to the listener.

    Parameters

    Returns ConvergenceEventEmitter<IConvergenceEvent>

    This object, in support of a fluent API.

removeAllListeners

removeListener

removeListeners

sessionId

  • sessionId(): string
  • Returns the session ID of the user session that created this reference.

    Returns string

source

type

  • Returns a string indicating the type of reference this is.

    Returns ReferenceType

user

  • Returns the user that created this reference.

    Returns DomainUser

value

  • value(): V
  • Returns the first value of the underlying reference.

    Returns V

values

  • values(): V[]
  • Returns all values of the underlying reference.

    Returns V[]

Object literals

Events

Events: object

A mapping of the events this instance could emit to each event's unique name. Use this to refer an event name:

reference.on(ModelReference.Events.SET, function listener(e) {
  // ...
})

CLEARED

CLEARED: string = ReferenceClearedEvent.NAME

DISPOSED

DISPOSED: string = ReferenceDisposedEvent.NAME

SET

SET: string = ReferenceSetEvent.NAME

Types

Types: object

All the types of references available on the various RealTimeElements.

ELEMENT

ELEMENT: "element" = "element"

INDEX

INDEX: "index" = "index"

PROPERTY

PROPERTY: "property" = "property"

RANGE

RANGE: "range" = "range"