I am using ngrx/store and ngrx/effects.
This is the flow,
Question: I would like to perform some UI task, eg, pull down the modal, or show a pop up of the error message, after the action.
How would I go about subscribing to the response in my component?
Thanks guys.
Your state should have a flag that would notify your component that it should do an action.
Something like this:
State:
const initialState: SomeState = {
loggedIn: false,
...
};
export default function(state = initialState, action: Action): SomeState {
switch (action.type) {
case StateActions.LOGIN_SUCCESS:
return Object.assign({}, state, {loggedIn: true});
...
Then in your component you subscribe to the state and if loggedIn
is true you know that you should for example show the modal.
Another approach would be to perform the task right in your effect through a service.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With