Options
All
  • Public
  • Public/Protected
  • All
Menu

Module MessageLoop

The namespace for the global singleton message loop.

Index

Type aliases

ExceptionHandler

ExceptionHandler: function

A type alias for the exception handler function.

Type declaration

    • (err: Error): void
    • Parameters

      • err: Error

      Returns void

Functions

clearData

  • Clear all message data associated with a message handler.

    Parameters

    • handler: IMessageHandler

      The message handler of interest.

      Notes

      This will clear all posted messages and hooks for the handler.

    Returns void

flush

  • flush(): void
  • Process the pending posted messages in the queue immediately.

    Notes

    This function is useful when posted messages must be processed immediately, instead of on the next animation frame.

    This function should normally not be needed, but it may be required to work around certain browser idiosyncrasies.

    Recursing into this function is a no-op.

    Returns void

getExceptionHandler

  • Get the message loop exception handler.

    Returns ExceptionHandler

    The current exception handler.

    Notes

    The default exception handler is console.error.

installMessageHook

  • Install a message hook for a message handler.

    Parameters

    • handler: IMessageHandler

      The message handler of interest.

    • hook: MessageHook

      The message hook to install.

      Notes

      A message hook is invoked before a message is delivered to the handler. If the hook returns false, no other hooks will be invoked and the message will not be delivered to the handler.

      The most recently installed message hook is executed first.

      If the hook is already installed, this is a no-op.

    Returns void

postMessage

  • Post a message to a message handler to process in the future.

    Parameters

    • handler: IMessageHandler

      The handler which should process the message.

    • msg: Message

      The message to post to the handler.

      Notes

      The message will be conflated with the pending posted messages for the handler, if possible. If the message is not conflated, it will be queued for normal delivery on the next cycle of the event loop.

      Exceptions in hooks and handlers will be caught and logged.

    Returns void

removeMessageHook

  • Remove an installed message hook for a message handler.

    Parameters

    • handler: IMessageHandler

      The message handler of interest.

    • hook: MessageHook

      The message hook to remove.

      Notes

      It is safe to call this function while the hook is executing.

      If the hook is not installed, this is a no-op.

    Returns void

sendMessage

  • Send a message to a message handler to process immediately.

    Parameters

    • handler: IMessageHandler

      The handler which should process the message.

    • msg: Message

      The message to deliver to the handler.

      Notes

      The message will first be sent through any installed message hooks for the handler. If the message passes all hooks, it will then be delivered to the processMessage method of the handler.

      The message will not be conflated with pending posted messages.

      Exceptions in hooks and handlers will be caught and logged.

    Returns void

setExceptionHandler

  • Set the message loop exception handler.

    Parameters

    Returns ExceptionHandler

    The old exception handler.

    Notes

    The exception handler is invoked when a message handler or a message hook throws an exception.

Generated using TypeDoc