warp-contracts-pubsub
v1.0.8
Published
Pub/sub library for warp contracts
Downloads
80
Readme
Streamr
Configure client
Create client:
const client = new StreamrWsClient({
direction: 'all'
});
Please see StreamrConnectionOptions for more configuration details.
Subscribe to a stream
const streamId = 'streamId';
const pubsub = await StreamrWsClient.create({
direction: 'sub',
streamId: streamId
});
pubsub.sub(
(data) => console.log(data),
(err) => console.error('Failed to subscribe:', err)
);
Publish to a stream
const streamId = 'streamId';
const pubsub = StreamrWsClient.create({
direction: 'sub',
streamId: streamId
});
const data = { some: 'object' };
pubsub.pub(data, (err) => console.error('Failed to publish:', err));