-
Notifications
You must be signed in to change notification settings - Fork 1
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
Pull sampler when input source emits #1
Comments
Hm, I don't think your sample code would work, but I could have missed something. The inner pipe isn't being pulled, so actually fromIter would never emit. Could you maybe also describe your use case a little bit more? I'm having slightly hard time to understand what you are trying to achieve. Do you want to pull from source A based on emissions from source A? |
Exactly; the inner source is never pulled, so it doesn't work.
Not quite. Consider a pipeline of the following form. const output = pullWhen(puller)(input); So The idea is to inform
I'll create a pull request with this feature. That will hopefully clearify what I mean. |
I'm really curious about how you want this to be implemented - gonna wait for a PR demonstrating it. I'm still not sure if this should be a part of this operator though, but I'm open for further discussion. Seems to me that it could be implemented on top of existing operators without extending this one. |
First of all, I wanted to say I like how this operator allows to interfrate pullable and listenable sources to form powerful complex pipelines.
In this sense, I propose a feature request which would make it even more powerful.
With the current implementation, we can provide a listenable sampler that tells us when to pull, e.g. an
interval
that emits every second.However, there is no easy way to pull the source based on its emissions, like pulling it whenever it another item whenever we get one etc.
But this can easily be achieved by pulling the sampler whenever the input emits, possible passing along the data as well.
This simple (andfully backwards-compatible) change would open some cool possibilities.
For example, you could can pull another item after each emission, but first waiting a certain amount of time:
Another possibility would be to wait for
n
emissions before pullingn
more items.If you want, I can create a pull request for this.
The text was updated successfully, but these errors were encountered: