Options
All
  • Public
  • Public/Protected
  • All
Menu

Class OnEnginePlugin<M, S, T>

Used to provide a plugin with accessibility to an engine it is running on

Type parameters

Hierarchy

Implements

Index

Accessors

state

  • get state(): S
  • The plugin state contains fields which are universal across all plugins of each type (eg: status)

    Each plugin instance has its own state

    Returns S

store

  • get store(): T
  • The plugin store can be used to persist any custom data

    Use the generic parameter to specify a store interface

    Each plugin instance has its own store

    Returns T

Methods

createEngineSubscription

  • createEngineSubscription(name: string): Promise<Subscription<any>>
  • Create a subscription to a given topic on the engine plugin

    Parameters

    • name: string

      The pubsub topic name to subscribe to

    Returns Promise<Subscription<any>>

createSubscription

  • Create a subscription to a given topic on another plugin

    Parameters

    • target: ObjectId

      The target identifier for the plugin for the topic

    • name: string

      The pubsub topic name to subscribe to

    Returns Promise<Subscription<any>>

createTopic

  • createTopic(name: string): Topic<any>
  • Create a pubsub topic with a name (use dot seperation for nesting)

    Parameters

    • name: string

    Returns Topic<any>

destroy

  • destroy(): Promise<void>
  • Called when a plugin should destroy itself, this should be used with super.destroy()

    Returns Promise<void>

engineMethod

  • engineMethod(method: string): (Anonymous function)
  • Execute an instance method on the engine plugin through a proxy

    Parameters

    • method: string

      The method name to execute

    Returns (Anonymous function)

    A function which can be executed with the arguments to pass to target method

engineStaticMethod

  • engineStaticMethod(method: string): (Anonymous function)
  • Execute a static instance method on the engine plugin through a proxy

    Parameters

    • method: string

      The method name to execute

    Returns (Anonymous function)

    A function which can be executed with the arguments to pass to target method

init

  • init(): Promise<void>
  • Called when a plugin should initialize itself, this should be used with super.init()

    All plugins have been constructed at this point

    Returns Promise<void>

method

  • method(target: ObjectId, method: string): (Anonymous function)
  • Execute an instance method on another plugin through a proxy

    Parameters

    • target: ObjectId

      The plugin instance to use

    • method: string

      The method name to execute

    Returns (Anonymous function)

    A function which can be executed with the arguments to pass to target method

setState

  • setState(state: Partial<S>): Promise<void>
  • Update the plugin state and trigger stateDidUpdate notifications

    Parameters

    • state: Partial<S>

      Object to merge into existing state (only root keys are merged)

    Returns Promise<void>

setStore

  • setStore(store: Partial<T>): Promise<void>
  • Update the plugin store and trigger storeDidUpdate notifications

    Parameters

    Returns Promise<void>

stateDidUpdate

  • stateDidUpdate(prevState: S): void
  • Notify the plugin that a state change has taken place

    Parameters

    • prevState: S

      The previous state object which has been replaced

    Returns void

staticMethod

  • staticMethod(plugin: ObjectId, method: string): (Anonymous function)
  • Execute a static method on another plugin through a proxy

    Parameters

    • plugin: ObjectId
    • method: string

      The method name to execute

    Returns (Anonymous function)

    A function which can be executed with the arguments to pass to target method

storeDidUpdate

  • storeDidUpdate(prevStore: T): void
  • Notify the plugin that a store change has taken place

    Parameters

    • prevStore: T

      The previous store object which has been replaced

    Returns void

Static createPrototype

  • Create a new model for a given prototype

    Parameters

    • prototype: IPrototypeModel

      The full prototype model, should be used for context

    • name: string

      Name of the model that should be created

    Returns object

    The model to be created

Static staticMethod

  • staticMethod(plugin: ObjectId, method: string): (Anonymous function)
  • Execute a static instance method on another plugin through a proxy

    Parameters

    • plugin: ObjectId
    • method: string

      The method name to execute

    Returns (Anonymous function)

    A function which can be executed with the arguments to pass to target method