Skip to content

Is there a blockUntil implementation? #4336

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

Closed
chaviw opened this issue Aug 10, 2016 · 11 comments
Closed

Is there a blockUntil implementation? #4336

chaviw opened this issue Aug 10, 2016 · 11 comments
Labels

Comments

@chaviw
Copy link

chaviw commented Aug 10, 2016

I was searching through the docs and there doesn't seem to be any blockUntil. There's a waitUntil and doUntil, but I was hoping for something a bit different.

It would be nice to have a way to hold data until something triggers the "unblock". This way, after the "unblock" each piece of data can be grabbed without losing anything.

Are there plans to build a blockUntil? I'd be happy to help contribute on that.

@akarnokd
Copy link
Member

I can't remember any waitUntil or doUntil in RxJava; are you sure you posted to the right library? There was an operator PR pressureValve that offered a second channel to pause a main channel losslessly and non-blockingly, but it's on hold for now.

@chaviw
Copy link
Author

chaviw commented Aug 10, 2016

My bad, I meant skipUntil and takeUntil, but none of those block the emission

@chaviw
Copy link
Author

chaviw commented Aug 10, 2016

And yes, I think that pr is similar to what I want

@JakeWharton
Copy link
Contributor

That sounds like it would be named bufferWhile

@chaviw
Copy link
Author

chaviw commented Aug 10, 2016

Sure, that makes sense. So I'm guessing there's nothing in RxJava that handles that yet. If no ones working on it, then I can take a shot at it. Basically it would queue up data (maybe up to a specified limit) and then begins emissions after the condition is met

@akarnokd
Copy link
Member

What is your use case?

@chaviw
Copy link
Author

chaviw commented Aug 10, 2016

To be as specific without going into implementation details:
As soon as the app is opened, "A" is started. The execution is asynchronous. The user can still interact with the app by invoking "B". "B" should NEVER start until "A" is done otherwise things will break. We want to queue up all the "B" tasks so after "A" is done, all the "B" interaction will get handled

An additional note, we can't stop the user from invoking "B" before "A" is done. Not because of requirements, but because of the nature of mobile devices.

In our first attempt, we just canceled "A" when "B" occurred and started again. This can lead to a slower start time for the user.

The current implementation waits for "A" to finish and then grabs the last state "B" to invoke. That's obviously not ideal because we can possibly lose data

@akarnokd
Copy link
Member

Sounds like you need concatEager that prestarts all sources but keeps ordering among them.

@chaviw
Copy link
Author

chaviw commented Aug 10, 2016

That might work. I'll try that out and see if it works for our use-case. Thanks

@chaviw
Copy link
Author

chaviw commented Aug 10, 2016

I dug a bit more into concatEager and it's not exactly what I need.

I think I found another way to fix my issue and not lose data. However, I still think having a bufferWhile would be nice. It would look something like bufferWhile(Observable<U> other) which will begin emitting once the other Observable emits an item

@akarnokd
Copy link
Member

akarnokd commented Sep 8, 2016

I'm closing this issue due to inactivity. If you have further input on the issue, don't hesitate to reopen this issue or post a new one.

@akarnokd akarnokd closed this as completed Sep 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants