8

I just opened a stream to listen for transactions. I'd like to know, how to close it, once I get what I am looking for. I can't find the close method in channel, or any of the objects for setting the channel to null, that would close it.

Sample code:

var channel = server.transactions()
    .forAccount(address)
    .cursor('now')
    .stream({ stuff });

Any ideas?

11

Call the returned object itself.

In your case: channel();

4

As described in the docs, TransactionCallBuilder.stream returns a function you can call to close a stream:

Returns:

Type: function

Close function. Run to close the connection and stop listening for new events.

1

I am just trying to make it more clear for the future visitors,

TransactionCallBuilder.stream returns the function to close the connection.

// Opens the stream channel
var streamChannel = server.transactions()
    .forAccount(address)
    .cursor('now')
    .stream({ stuff });

// Close the channel 
streamChannel()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.