Giter VIP home page Giter VIP logo

Comments (4)

didierfranc avatar didierfranc commented on May 28, 2024

Maybe what you're looking for is that kind of pattern https://github.com/didierfranc/react-waterfall/blob/master/examples/fetch/src/store/index.js#L13-L22

from react-waterfall.

digitive avatar digitive commented on May 28, 2024

Well, not exactly. Actually, I am try to find a way to set state multiple times inside an action, and each setState should trigger the ui updates. Though this could be done via calling other actions, still wondering more straight forward way to trigger state change instead of return only one state.

from react-waterfall.

didierfranc avatar didierfranc commented on May 28, 2024

You can't do that with redux, same here (action, state) => state but you can chain actions

from react-waterfall.

digitive avatar digitive commented on May 28, 2024

Something like this:

export function getEventList(filterText) {
  return async (dispatch, getState) => {
    try {
      const state = getState();
      const accountId = getActiveAccountId(state);
      dispatch({ type: GET_EVENT_LIST_LOADING, payload: { accountId } });
      const {
        eventList,
        events,
        timestamp,
      } = await api.getEventList(filterText);
      dispatch({ type: GET_EVENTS_COMPLETE, payload: eventsPayload });
      dispatch({ type: GET_EVENT_LIST_COMPLETE, payload: eventListPayload });
    } catch (err) {
      dispatch({ type: GET_EVENT_LIST_ERROR, payload: err });
    }
  };
}

Each dispatch() will trigger state change, and state changed multiple times within an action

from react-waterfall.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.