Options
All
  • Public
  • Public/Protected
  • All
Menu

Module @lauf/queue

Lightweight Message Queue

codecov

Logo - Image of Runner

Lauf Queue

Logo - Diego Naive, Noun Project.

Install

npm install @lauf/queue --save

@lauf/queue provides a minimal in-memory MessageQueue solution. It is incredibly lightweight with no dependencies and is suitable for adoption server-side or client-side in Typescript or Javascript.

A MessageQueue is like a mailbox. Your async code can await queue.receive() until the next message is available. In this way, one or more workers can consume and process bespoke application events in strict sequence.

For applications using @lauf/store, the @lauf/store-follow package can be used to create a MessageQueue notifying changes to a Selector.

Browse the API.

Index

Interfaces

Type aliases

Functions

Type aliases

Watcher

Watcher<T>: (item: T) => unknown

Type parameters

  • T

Type declaration

    • (item: T): unknown
    • Function subscribed to be notified of an item T.

      Parameters

      • item: T

      Returns unknown

Functions

createQueue

  • createQueue<T>(messageBacklog?: number, receiverBacklog?: number): MessageQueue<T>
  • Create a new MessageQueue, with no backlog limits by default.

    Type parameters

    • T

    Parameters

    • Optional messageBacklog: number

      Maximum backlog of waiting messages before [[send()]] returns false

    • Optional receiverBacklog: number

      Maximum backlog of waiting receivers before [[receive()]] throws an Error

    Returns MessageQueue<T>

    a MessageQueue with the specified backlog limits

Generated using TypeDoc