News for hackers. Stuff that matters.
Re:Show HN: Build your first real world React.js application by yawgmoth on Wednesday September 07, 2016 @05:45PM (#12448067)
It's an example of the thunk pattern. Thunks are used when you have an async call, e.g. getFoos. Then your action creator would be

  function requestFoos() {
    return { type: REQ_FOOS }
  }

  function gotFoos(foos) {
    return { type: GOT_FOOS, foos }
  }

  export function getFoos() {
    return function(dispatch) { 
      dispatch(requestFoos());
      myFooProvider
        .getFoos()
        .then(function(foos) { dispatch(gotFoos(foos)); });
    }
  }
Really useful for writing reducers that want to keep track of when you're fetching data from the server.
Re:Show HN: Build your first real world React.js application by hamandcheese on Thursday September 08, 2016 @01:56PM (#12455385)
Yes, but in the parent comment a thunk wasn't being dispatched, but rather a closure around some unknown dispatch function is being called.