simpleledgerinc / grpc-bchrpc-node

A BCHD gRPC client for node.js
10 stars 10 forks source link

Strongly typed subscriptions #3

Open elderapo opened 4 years ago

elderapo commented 4 years ago

It would be cool if subscriptions were strongly typed. Right now they look like this:

const stream = await client.subscribeTransactions({
  includeMempoolAcceptance: true
});

stream.on("data", tx => { // type of tx is any
  tx.??????
});

Maybe we could switch API a little bit like:

const cancel = client.subscribeTransactions({ ...opts }, (tx) => { //  type of tx wil be TransactionNotification

});

cancel(); // to stop listening
jcramer commented 4 years ago

Another great suggestion, we can do that.