Add a .execute
as a .subscribe
alternative
#6619
Sawtaytoes
started this conversation in
Ideas / Feature request
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I built an
execute
function to wrap RxJS observables for synchronous execution:The
.unsubscribe
is only there in case someone puts adelay
or something else async in the pipeline. You'd getundefined
in that case which is expected.It'd be nice if this were part of RxJS as an alternative to
.subscribe
, so I don't have to copy-paste it into every project that needs it.While it seems useless, there are good reasons you might want to use RxJS for synchronous execution; although, I know it's not the standard use case since most people don't need it.
Since it's so simple to write one of these, I could keep copy-pasting it, but I think adding it natively in the library would be helpful to anyone that needs this functionality.
In the case of a
BehaviorSubject
, it already has a.value
prop, but this is meant for synchronous execution where you don't have to worry about subscribing and unsubscribing.Beta Was this translation helpful? Give feedback.
All reactions