Create a Redux-saga listener

69
December 28, 2018, at 2:40 PM

I have a UPDATE_DATE action on redux saga. I want to update multiple resources every time that Date is modified. I would like to implement a listener to action UPDATE_DATE_SUCCESS that triggers a callback. Any idea? I would be great if I can call it from the React component.

Action: UPDATE_DATE UPDATE_DATE_SUCCESS UPDATE_DATE_FAILURE

export const {
  updateDate,
  OnDateChange,
} = createActions({
  [ActionTypes.UPDATE_DATE]: (date) => date,
});

Saga

export function* updateDate(newDate) {
  console.log('from sagas to reducer', newDate); // eslint-disable-line no-console
  try {
    yield put({
      type: ActionTypes.UPDATE_DATE_SUCCESS,
      payload: newDate,
    });
  } catch (err) {
    /* istanbul ignore next */
    yield put({
      type: ActionTypes.UPDATE_DATE_FAILURE,
      payload: err,
    });
  }
}
export default function* root() {
  yield all([
    takeLatest(ActionTypes.UPDATE_DATE, updateDate),
    takeEvery(ActionTypes.UPDATE_DATE_SUCCESS, test),
  ]);
}

Desirable implementation on React Component

  componentDidMount() {
    const { dispatch } = this.props;
    dispatch(onDateChange((newDate) => {
        dispatch(getApps(newDate));
        dispatch(getPlatforms(newDate));
        dispatch(getNetworks(newDate));
        dispatch(getCountries(newDate));
        dispatch(getFormats(newDate));
        dispatch(getDevices(newDate));
        dispatch(getNetworkKeys(newDate));
    }));
  }

Any help? thank you!

READ ALSO
How to router with knockoutJS, javascript or jquery?

How to router with knockoutJS, javascript or jquery?

I asked a question hereHow to display text in loop with knockout js How to display text in loop with knockout js I want to add routing url like website

55
GraphQL: How nested to make schema?

GraphQL: How nested to make schema?

This past year I converted an application to use GraphqlIts been great so far, during the conversion I essentially ported all my services that backed my REST endpoints to back grapqhl queries and mutations

38
How do I encrypt a string variable using Fernet encryption

How do I encrypt a string variable using Fernet encryption

Hello I am trying to encrypt this variable using the Fernet method from the cryptogrphy module

40
Css Won't Connect To Html [on hold]

Css Won't Connect To Html [on hold]

I Am Getting The Same Thing, But Neither Of The Top Two Suggestions Worked: Html-

40