Integrating Redux best practices Ionic 2/3+


#1

After having recently rewired my entire application’s Redux implementation I want to find better ways and practices for using Redux. My implementation does not depend on redux for all state changes since I am not using Redux for my forms or interaction with the Ionic Storage service. Yet, dramatic simplification happened to each part of my app I do use Redux for. I am running into a few challenges as I use Redux:

  1. Setting up loading dialogs has been a challenge. Sometimes my loading dialogs are triggered more than once and sometimes they stay on the screen forever.
  2. Effects on app.component.ts always run twice for whatever reason even though I properly unsubscribe from every Rxjs Subscription.

Another area I want to improve is my navigation. Now all navigation in my app is controlled by Redux actions. The only place my app uses NavController is in my NavigationEffects class since it uses @ngrx/effects. Is that a good way to do things? The app doesn’t use any nav-params since it just has subscriptions to the store in container component.

I really like the way Redux has given my app a consistent way to manage state and would like to gain additional benefits available from other parts of the Redux ecosystem. I have learned about Thunks and Sagas and have yet to use them. Are there other things that would make my Redux implementation even better?


#2

My redux experience is mostly with ngrx, and recently I tried to write an “ngrx for Stencil” but I had to put that on pause, because Stencil doesn’t have enough generic support yet. Here’s what I think.

  1. I created a LoadingManager provider. If a page wants to show a loading message, it requests the provider do it. The provider ensures that at most one message is live at a time, and does some other bookkeeping too.

  2. There’s almost certainly something wrong in your code if you have effects firing twice.

  3. Ionic 4 will connect to the Angular Router, so the standard ngrx routing techniques will finally be available.

  4. The existing stencil-redux (very simple, no generics, no effects) is good enough for light apps. So that’s a way to have a redux experience that renders faster than Ionic-Angular.


#3

Ionic 4 isn’t quite ready for all this correct? Isn’t it still very beta? Would you recommend waiting?