Skip to content

Conversation

@Andrew-Bekhiet
Copy link

Adds a new operator that works like startWith but accepts a future

The whole idea is like this:

Stream.fromFuture(someFuture).switchMap((resolvedValue) => this.startWith(resolvedValue))

@hoc081098
Copy link
Owner

hoc081098 commented Dec 26, 2022

Is this operator necessary? I think using Rx.concat([future.asStream(), this]) is more idiomatic

@Andrew-Bekhiet
Copy link
Author

I found myself repeating the implementation in my code so I wrote the extension and thought it might be useful for others too

Hmm yeah sure I think I just wrote the implementation that first came to my mind

@hoc081098
Copy link
Owner

@Andrew-Bekhiet.
It is not clear if we use it with broadcast stream, we can miss events before the future completes.
Either concat or concatEager is the best for all cases?

test(startWithFuture): simulate delay to ensure no events were dropped
@Andrew-Bekhiet
Copy link
Author

Sorry for being a little too late for this

Yes I think concatEager will be better so I changed the implementation

@hoc081098
Copy link
Owner

Sorry for being a little too late for this

Yes I think concatEager will be better so I changed the implementation

Thanks 👍
I will look at it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants