@stellar-expert/horizon-streamer

0.1.1 • Public • Published

Horizon Streamer

Streaming wrapper for Stellar Horizon server.

Usage

Install the package.

npm install -S @stellar-expert/horizon-streamer

Stream effects.

import horizonStreamer from '@stellar-expert/horizon-streamer'
import {Server} from 'stellar-sdk'

const horizon = new Server('https://horizon.stellar.org/')

const finalize = horizonStreamer({
    //any horizon call builder which supports streaming
    callBuilder: horizon.effects(),
    //cursor to start from, live blank to stream from the start or use 'now' to start from the most recent record 
    cursor: '12884905985-3', 
    //callback handler that returns fetched entries one by one
    onNewRecord: function (entry) {
        console.log(entry)
        return Promise.resolve()
    }
})

//destroy the streamer when finished
setTimeout(() => finalize(), 1000)

Tests

npm run test

Readme

Keywords

Package Sidebar

Install

npm i @stellar-expert/horizon-streamer

Weekly Downloads

1

Version

0.1.1

License

MIT

Unpacked Size

6.77 kB

Total Files

6

Last publish

Collaborators

  • orbitlens