question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItĀ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Do the design of ActionsObservable and StateObservable make sense with RxJS 6 thinking?

See original GitHub issue

I noticed that these observables are going to remain in existence (or exist in the case of StateObservable) but they kind of go counter to the new way of creating Observables in RxJS 6. The static class methods are all going away in favor of creation functions. So instead of exporting the ActionsObservable you change the documentation to show a user how to use rxjs’s of and from? The ones on the ActionsObservable seem to be pass-throughs.

As for the StateObservable I can’t say that’s as straightforward but it’d be nice to have the creation method pattern for both be like using the creation functions from RxJS 6. I’m sorry if I’m unclear here. I’m trying to read through the sources to see if I’m understanding right and working on a wip branch to migrate to RxJS 6 and redux-observable 1 so I wanted to make sure I migrate my tests idiomatically. šŸ˜„

Which versions of redux-observable, and which browser and OS are affected by this issue? Did this work in previous versions of redux-observable?

1.0.0alpha2

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:2
  • Comments:17 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
jayphelpscommented, Apr 28, 2018

šŸ‘ You’re definitely correct thanks for kicking off the discussion and helping out šŸ™‚

I plan to remove ActionsObservable entirely, but StateObservable is needed because it differs in behavior than any other built-in Observable or Subject. It’s similar to BehaviorSubject except that it does not require an initial value. This is required because we setup your epics before the first action has been dispatched, so that you don’t miss it. If we used a BehaviorSubject and an epic subscribes to it on setup, it would receive undefined.

Having a creation function makes sense but I’ve struggling with naming since the simple names usually used might be confusing in this case. Any suggestions?

1reaction
jayphelpscommented, Aug 20, 2018

@Pappa you’ve actually found a bug in rxjs that was indeed introduced as part of rxjs#3504. That PR intended to only skip subscribing to the source if the notifier emits a value synchronously but instead skips subscribing if the notifier completes synchronously.

I’ve made a PR to fix this upstream: https://github.com/ReactiveX/rxjs/pull/4039

Until this is fixed, the solution is to make each action emitted async by scheduling using the AsyncScheduler. In the case of ActionsObservable.of() it can be provided as the last argument.

If you’re using redux-observable v1 and rxjs v6 you also no longer need to use ActionsObservable, you could just use regular Observable of() from import { of } from 'rxjs'

Here’s a stackblitz: https://stackblitz.com/edit/redux-observable-v1-playground-ewvnvq?file=index.js

import { asyncScheduler } from 'rxjs';
// etc...
const action$ = of(loginSuccessAction(), asyncScheduler);

This works because the action$ stream won’t synchronously complete then.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular Application Architecture: Build Reux-like Apps with RxJs
In this post, we are going to walk through how Angular applications can be built in a Functional Reactive style using the RxJs...
Read more >
A Beginner's Guide to RxJS & Redux Observable
Redux-Observable is an RxJS-based middleware for Redux that allows developers to work with async actions. It's an alternative to redux-thunkĀ ...
Read more >
forkEpic, redux-observable 1.0.0-alpha.2, typescript
So the issue is that the forkEpic function is invoking getRailwaysEpic locally and because it is using switchMap it is swallowing aĀ ...
Read more >
redux-observable/redux-observable - Gitter
@ivanov-v why can't you just use rxjs and make an observable? ... S = void, D = any> { (action$: ActionsObservable<T>, state$: StateObservable<S>,Ā ......
Read more >
Simple yet powerful state management in Angular with RxJS
Let's create our own state management Class which can be extended by Angular services. Tagged with rxjs, angular, javascript, webdev.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found