Options
All
  • Public
  • Public/Protected
  • All
Menu

Class AbstractRuntime<Events> Abstract

Skeletal implementation of IRuntime that uses a root Collab.

Type Parameters

Hierarchy

Implements

Index

Constructors

Properties

isRuntime: true = true
replicaID: string

A unique ID for this replica (copy of a Collabs document).

Methods

  • emit<K>(eventName: K, event: Events[K]): void
  • Emits an event, which triggers all the registered event handlers.

    Event handlers are called in the order they are added. Errors in event handlers are captured and logged (with console.error), not propagated to the caller.

    Type Parameters

    • K extends string | number | symbol

    Parameters

    • eventName: K

      Name of the event to emit.

    • event: Events[K]

      Event object to pass to the event handlers.

    Returns void

  • fromID<C>(id: CollabID<C>): undefined | C
  • on<K>(eventName: K, handler: ((event: Events[K], caller: AbstractRuntime<Events>) => void), options?: { once?: boolean }): (() => void)
  • Registers an event handler that is triggered when the event happens.

    Type Parameters

    • K extends string | number | symbol

    Parameters

    • eventName: K

      Name of the event to listen on.

    • handler: ((event: Events[K], caller: AbstractRuntime<Events>) => void)

      Callback that handles the event.

    • Optional options: { once?: boolean }
      • Optional once?: boolean

        If true, the event handler is triggered at most once (the next time the event happens), then unsubscribed.

    Returns (() => void)

    An "off" function that removes the event handler when called.

      • (): void
      • Registers an event handler that is triggered when the event happens.

        Returns void

        An "off" function that removes the event handler when called.

  • setRootCollab<C>(rootCallback: ((init: InitToken) => C)): C

Generated using TypeDoc