Search code examples
angularerror-handlingngrxngrx-storengrx-effects

How to handle errors from ngrx effect 's catch block and send it to store in component?


I want to handle the loadfailure sceanrio from my component so that I can handle the no data in view html. Should I add selectors for error sceanrio or handle it in effects. I am pretty novice to ngrx style of fetching data based on actions


Solution

  • Added the error state to the NgRx store is the most straightforward approach. With selectors you can read the error state and re-render the component.

    Brandon Roberts wrote a detailed article with some alternatives, for more info see https://brandonroberts.dev/blog/posts/2019-03-04-handling-error-states-with-ngrx/