-
Notifications
You must be signed in to change notification settings - Fork 147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to handle a hot source? #292
Comments
Highland has no concept of a "hot" vs "cold" source. That's one of the main differences between Highland and Rx. Rx Observables can typically be subscribed to multiple times, while a highland stream can only be There's also no way to handle unsubscriptions automatically right now. That's something I've been meaning to tackle, but I haven't had the time. See #172 for relevant discussions. The best you can do right now is _(function (push, next) {
const changes = this.changes(options)
changes
// Pass the object along so you can manually cancel.
.on('change'), (change) => push(null, [changes, change]))
.on('complete'), (info) => push(null, _.nil))
.on('error', (err) => push(err))
}); |
Started an initial try to make a pause/resumable changes stream. pouchdb/pouchdb#3772 However, haven't found any good examples/documentation on how to create a pause/resumable highland stream. |
To create a pausable stream from a hot source, you need a backpressure strategy. The default strategy is to buffer. latest implements another. A third (that isn't implemented) is You should never need to implement _(function cb(push, next) {
...
});
Thus, a backpressure-aware generator will typically
Note that the You can look at the code for latest to see how to change the backpressure strategy after the fact. Or you can implement the desired strategy directly in the generator (I suggest doing it after the fact in a separate transform for additional composability). For example, with a
|
Thanks. |
I'm trying to convert the following RxJS code to HighlandJS but I'm unsure how to handle a "hot" source.
i.e. how would I do the following in highland?
It is the "changes" feed in PouchDB that I'd like to highlandify: http://pouchdb.com/api.html#changes
The text was updated successfully, but these errors were encountered: