ixfx
    Preparing search index...

    Class QueueMutable<V>

    Mutable queue that fires events when manipulated.

    Queues are useful if you want to treat 'older' or 'newer' items differently. Enqueing adds items at the back of the queue, while dequeing removes items from the front (ie. the oldest).

    const q = Queues.mutable();       // Create
    q.enqueue(`a`, `b`); // Add two strings
    const front = q.dequeue(); // `a` is at the front of queue (oldest)
    const q = Queues.mutable({capacity: 5, discardPolicy: `newer`});
    

    Events can be used to monitor data flows.

    • 'enqueue': fires when item(s) are added
    • 'dequeue': fires when an item is dequeued from front
    • 'removed': fires when an item is dequeued, queue is cleared or .removeWhere is used to trim queue

    Each of the event handlers return the state of the queue as the 'finalData' field.

    q.addEventListener(`enqueue`, e => {
    // e.added, e.finalData
    });
    q.addEventListener(`removed`, e => {
    // e.removed, e.finalData
    });
    q.addEventListener(`dequeue`, e=> {
    // e.removed, e.finalData
    })

    Type Parameters

    • V

      Data type of items

    Hierarchy (View Summary)

    Implements

    Index

    Accessors

    Constructors

    Methods

    Properties

    data: readonly V[]
    eq: IsEqual<V>
    options: QueueOpts<V>