tweb3-core-subscriptions
v0.1.0
Published
Manages tweb3 subscriptions. This is an internal package.
Downloads
7
Readme
tweb3-core-subscriptions
This is a sub package of [tweb3.js][repo]
The subscriptions package used within some [tweb3.js][repo] packages. Please read the [documentation][docs] for more.
Installation
Node.js
npm install tweb3-core-subscriptions
In the Browser
Build running the following in the [tweb3.js][repo] repository:
npm run-script build-all
Then include dist/tweb3-core-subscriptions.js
in your html file.
This will expose the Web3Subscriptions
object on the window object.
Usage
// in node.js
var Web3Subscriptions = require('tweb3-core-subscriptions');
var sub = new Web3Subscriptions({
name: 'subscribe',
type: 'tnb',
subscriptions: {
'newBlockHeaders': {
subscriptionName: 'newHeads',
params: 0,
outputFormatter: formatters.outputBlockFormatter
},
'pendingTransactions': {
params: 0,
outputFormatter: formatters.outputTransactionFormatter
}
}
});
sub.attachToObject(myCoolLib);
myCoolLib.subscribe('newBlockHeaders', function(){ ... });