You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

composer-events-subscriber

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

composer-events-subscriber

Subscribe to business network events

1.0.1
latest
Source
npmnpm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

composer-events-subscriber

Purpose

Composer create for us a set of transactions to make CRUD operations on assets and participants. For now, it's not possible to listen for events from those transactions without using the native api. This module connects to an eventHub from your hyperledger fabric network, and listens for all transactions that are submitted. It dispatchs all events that you can listen to do what you need.

Infos

The class Subscriber extends the node js EventEmitter from events module

install

Using npm

npm install composer-events-subscriber --save

Or using yarn

yarn add composer-events-subscriber

Usage

Listen for all transactions

import Subscriber from 'composer-events-subscriber'

//connect to the business network using the composer-client
businessNetwork.connect('cardName').then((invokedTx, historianTx) => {
    const subscriber = new Subscriber(businessNetwork)
    //subscribe to event hub
    const unsubscribe = subscriber.subscribe()
    //listen for all transaction
    subscriber.on('tx', (tx, historianTx)=> {
        console.log('All events')
    }).on('error', e => {
        console.log('ERROR')
    })
    //unsubscribe on process exit
    process.on('exit', () => unsubscribe())
})

Listen for named transactions

import Subscriber from 'composer-events-subscriber'

//connect to the business network using the composer-client
businessNetwork.connect('cardName').then(=> {
    const subscriber = new Subscriber(businessNetwork)
    //subscribe to event hub
    const unsubscribe = subscriber.subscribe()
    //listen for a named transaction
    subscriber.on('tx:org.hyperledger.composer.system.UpdateParticipant', (tx, historianTx) => {
        console.log('EVENT')
    }).on('error', e => {
        console.log('ERROR')
    })
    //unsubscribe on process exit
    process.on('exit', () => unsubscribe())
})

Keywords

blockchain

FAQs

Package last updated on 07 Mar 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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.