waytale - v0.5.1
    Preparing search index...

    Class WaytaleModel

    The class to rule them all: Main instance that contains state information divided into components.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    database: WaytaleDatabase | null = null
    events: WaytaleEvents = ...
    map: WaytaleMap | null = null

    Currently loaded map.

    next_update_check: number | null = null
    settings: Settings

    Settings object, synchronised with database.

    space: WaytaleSpace | null = null

    Currently loaded space.

    timestamp: Date = ...

    Moment of Waytale initialisation.

    userIdentity: WaytaleUserIdentity | null = null

    The unique identity of the current user.

    Methods

    • Unsubscribe from an event by name with a specific handler.

      Parameters

      • eventName: any

        event to unsubscribe from

      • handler: any

        callback handling the event

      Returns void

    • Subscribe to an event by name with a specific handler.

      Parameters

      • eventName: any

        event to subscribe to

      • handler: any

        callback handling the event

      Returns void

    • Subscribe to an event, but run the handler only once. After running exactly once the handler will be immediately unsubscribed.

      Parameters

      • eventName: any

        event to subscribe to

      • handler: any

        callback handling the event

      Returns void

    • Trigger the calls of the event handlers subscribed to the given event.

      Parameters

      • eventName: any

        event to trigger

      • ...args: any[]

        arguments to forward to the event handlers

      Returns void

    • Change the value of a property and trigger an event of the same name. A second event is triggered where the event name is the name of the property suffixed by the name of the operation.

      The event handlers will be called with the parameters of (in this order) the new value, the old value, and a reference to this.

      The method parameter specifies how the value is updated depending on whether the property is a normal value, an array, or an object. The respective value in parentheses is used as the suffix for the second trigger call.

      • assign for normal assignment (Assign)
      • prepend, append, and remove for arrays (Add, Add, Remove)
      • insert, replace, and delete for objects and maps (Insert, Replace, Delete)

      For operations on objects, the extra parameter is used as "key" i.e. property name.

      Parameters

      • key: any

        the name of the property

      • value: any

        the new value

      • method: string = 'assign'

        how to update, see description

      • extra: any = undefined

        key to use for object operations

      Returns void