@egomobile/queue
TypeScript icon, indicating that this package has built-in type declarations

3.3.2 • Public • Published

npm last build PRs Welcome

@egomobile/queue

A simple and powerful queue implementation.

Install

Execute the following command from your project folder, where your package.json file is stored:

npm install --save @egomobile/queue

Usage

import { Queue } from "@egomobile/queue";

let queue!: Queue;

async function main() {
  queue = new Queue();

  // register 2 tasks at once
  queue.register({
    // 1st
    "my task 1": async (context) => {
      console.log("This is task 1 with following data:", context.data);
    },

    // 2nd
    "my task 2": async (context) => {
      console.log("This is task 2 with following data:", context.data);
    },
  });

  // anything is prepared, lets start the queue
  await queue.start();

  // first enqueue 2nd task
  await queue.enqueue("my task 2", {
    buzz: 5979,
  });
  // then 1st one
  await queue.enqueue("my task 1", {
    foo: "bar",
  });
}

main().catch(console.error);

Documentation

The API documentation can be found here.

Package Sidebar

Install

npm i @egomobile/queue

Weekly Downloads

2

Version

3.3.2

License

LGPL-3.0

Unpacked Size

42 kB

Total Files

20

Last publish

Collaborators

  • ekmobile
  • egodux
  • mkloubertego
  • mkloubert
  • ekegodigital