Stone.js API
    Preparing search index...

    Class representing an IncomingEvent.

    Mr. Stone evensstone@gmail.com

    Hierarchy (View Summary)

    Index
    locale: string

    The locale of the event.

    metadata: Record<string, unknown>

    The metadata associated with the event.

    The source of the event.

    timeStamp: number

    The timestamp of the event creation.

    type: string

    The type of the event.

    • get platform(): string | symbol

      Get the platform of the event source.

      Returns string | symbol

      The platform of the event source.

    • Return a cloned instance.

      The metadata container is deep-copied (plain objects and arrays are recreated, special values kept by reference) so that mutating the clone's metadata — e.g. via middleware — never leaks back into the original event. This is what makes the Kernel's originalEvent snapshot a faithful pre-middleware copy.

      Returns this

      A cloned instance of the current class.

    • A stable identity for this event.

      What it is for: keying anything that has to survive one event being handled twice. A renderer stores its loader results under this key on the server and reads them back under the same key in the browser, so two renders of the same event find the same data.

      Defined here because identity is not a platform's idea. An event that carries a URL has a sharper one to offer and overrides this: IncomingHttpEvent and IncomingBrowserEvent both answer with their method and path. An event that carries a payload instead, from a queue or a timer, is identified by that payload, which is what this computes.

      Two properties it must have, and both come from what is excluded: the timestamp is left out, because a server render and a browser render of the same event happen at different moments and must agree; and keys are sorted, because two objects with the same entries in a different order are the same event.

      Returns string

      The fingerprint, base64-encoded.

    • Get data from metadata.

      Type Parameters

      • TReturn = unknown

      Parameters

      • key: string

        The key to retrieve from metadata.

      Returns TReturn

      The value associated with the key or the fallback.

    • Get data from metadata.

      Type Parameters

      • TReturn = unknown

      Parameters

      • key: string

        The key to retrieve from metadata.

      • fallback: TReturn

        The fallback value if the key is not found.

      Returns TReturn

      The value associated with the key or the fallback.

    • Get data from metadata.

      Type Parameters

      • TReturn = unknown

      Parameters

      • key: string

        The key to retrieve from metadata.

      Returns TReturn

      The value associated with the key or the fallback.

    • Get data from metadata.

      Type Parameters

      • TReturn = unknown

      Parameters

      • key: string

        The key to retrieve from metadata.

      • fallback: TReturn

        The fallback value if the key is not found.

      Returns TReturn

      The value associated with the key or the fallback.

    • Check if the given value is equal to the specified value.

      Parameters

      • key: string

        The key to check.

      • value: unknown

        The value to compare against.

      Returns boolean

      True if the key's value is equal to the specified value, false otherwise.

    • Check if the event source is from a platform.

      Parameters

      • platform: string | symbol

        The platform to check.

      Returns boolean

      True if the event source is from the platform, false otherwise.

    • Add data to metadata.

      Parameters

      • key: string | Record<string, unknown>

        The key or object to add to metadata.

      • Optionalvalue: unknown

        The value to associate with the key.

      Returns this

      This Event instance.

    INCOMING_EVENT: string = 'stonejs@incoming_event'

    INCOMING_EVENT Event name, fires on platform message.

    IncomingEvent#INCOMING_EVENT