9

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?

3 Answers 3

12

Call the returned object itself.

In your case: channel();

5

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.

0
2

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 and acknowledge you have read our privacy policy.

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