Skip to content
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

Applying scan after delay will delay the initial value #3387

Closed
mbrandonw opened this issue Sep 29, 2015 · 5 comments
Closed

Applying scan after delay will delay the initial value #3387

mbrandonw opened this issue Sep 29, 2015 · 5 comments
Labels

Comments

@mbrandonw
Copy link

Consider the following observable:

Observable.just(1)
  .delay(10, TimeUnit.Seconds)
  .scan(2, (accum, x) -> accum + x)

I would expect this to emit 2 immediately, and then 10 seconds later emit 3. Instead it waits 10 seconds, and then emits 2 and 3 immediately.

Am I interpreting this incorrectly?

@artem-zinnatullin
Copy link
Contributor

You're delaying emission of just(1), then operator scan() does it's job and emits two values without delay.

Try:

Observable
  .just(1)
  .scan(2, (accum, x) -> accum + x)
  .delay(10, SECONDS)

@akarnokd akarnokd added the Bug label Sep 30, 2015
@akarnokd
Copy link
Member

This is a bug with the scan operator emitting its initial value only when the first value arrived and has been fixed via #3171. It will be part of the next release.

@mbrandonw
Copy link
Author

Thanks @akarnokd. I only just realized this issue is related to #3168, which I also filed.

So just to confirm, the expected behavior of scan is to emit the initial value immediately, and then the accumulated values as they come?

@akarnokd
Copy link
Member

Exactly.

@mbrandonw
Copy link
Author

perf thanks!

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