@aloxide/demux
TypeScript icon, indicating that this package has built-in type declarations

0.6.1 • Public • Published

Table of content

Package @aloxide/demux

Implement demux pattern for sync data from blockchain to a centralized database.

Usage

real samples

ExpressActionWatcher: Exposes the API methods from the BaseActionWatcher through an Express server.

const expressWatcher = new ExpressActionWatcher(
  actionReader,
  actionHandler,
  pollInterval,
  portNumber,
);

expressWatcher.listen();

Now you can start watching for block data by making POST /start request, and to stop receiving block data by making POST /pause request. Between these requests, actionReader will read block data from the blockchain and passing it to actionHandler.

AloxideActionWatcher: A ready-to-use action watcher with ability to get only one block per request e.g. using in a lambda function.

Call watchOnce to read data of only one block (specified by startAtBlock option), for example when you want to read the blockchain once per lambda invocation.

const actionWatcher = new AloxideActionWatcher(actionReader, actionHandler, 1000);
await actionWatcher.watchOnce(); // `actionHandler` will be run once

Readme

Keywords

none

Package Sidebar

Install

npm i @aloxide/demux

Weekly Downloads

2

Version

0.6.1

License

Apache-2.0

Unpacked Size

94.3 kB

Total Files

58

Last publish

Collaborators

  • flowersinthesand
  • manhvu