New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@appchain/observables

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@appchain/observables

Observable based [CITA RPC](https://cryptape.github.io/cita/usage-guide/rpc/) toolkit

  • 0.20.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-83.33%
Maintainers
1
Weekly downloads
 
Created
Source

Travis npm MIT AppChain

Nervos-Observables

Observable based CITA RPC toolkit

Features

  • Supports Observable API

Installing

$ yarn add @nervos/observables

Example

import NervosObservables from 'nervos-observables'

const SERVER = 'localhost:1337'
const INTERVAL = 10
const RESERVED_RECORDS = 10

const nervosObservables = new NervosObservables({
  server: SERVER,
  interval: INTERVAL,
  reservedRecords: RESERVED_RECORDS,
})

/**
 * @function peerCount
 * @description subscribe to the count of peer
 * @param {string} interval - interval of observable
 * @param {boolean} observed - switch of observable, default to true, observing the peerCount
 * @return {string} count - peer count
 */
nervosObservables.peerCount(INTERVAL).subscribe(count => {
  console.log(count)
})

/**
 * @function newBlockNumber
 * @description subscribe to the latest block number
 * @param {string} interval - interval of observable
 * @param {boolean} observed - switch of observable, default to true, observing the new block number
 * @return {string} blockNumber - block number
 */
nervosObservables.newBlockNumber(INTERVAL).subscribe(blockNumber => {
  console.log(blockNumber)
})

/**
 * @function blockByNumber
 * @description request block by block number
 * @param {string} blockNumber
 * @return {object} block
 */
nervosObservables.blockByNumber(blockNumber).subscribe(block => {
  console.log(block)
})

/**
 * @function newBlockByNumber
 * @description subscribe to lastest block
 * @param {string} interval - interval of observable
 * @param {boolean} observed - switch of observable, default to true, observing the new block
 * @return {object} block
 */
nervosObservables.newBlockByNumber(INTERVAL).subscribe(block => {
  console.log(block)
})

/**
 * @function blockByHash
 * @description request block by block hash
 * @param {string} hash - block hash
 * @return {object} block
 */
nervosObservables.blockByHash(HASH).subscribe(block => {
  console.log(block)
})

/**
 * @function sendSignedTransaction
 * @description send signed transaction
 * @param {string} signedTransaction - signed transaction
 * @return {object} result
 */
nervosObservables.sendSignedTransaction(signedTransaction).subscribe(result => {
  console.log(result)
})

/**
 * @function newBlockByNumberSubject
 * @description subscribe to new block
 */
nervosObservable.newBlockByNumberSubject.subscribe(console.log)
nervosObservable.newBlockByNumberSubject.connect()

FAQs

Package last updated on 18 Dec 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc