Giter Site home page Giter Site logo

redux-ask's People

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

redux-ask's Issues

Chained Requests Examples

A lot of times users will want to make multiple requests in a row, perhaps using the response of one request as an input into another. We can do this with Redux Ask! But we need to show examples of this to make users aware.

// getUser & getUserFriends are pre-created requests (using createRequest)
handleSubmit = () => {
  const { userId, getUser, getUserFriends } = this.props;
  getUser(userId)
    .then(user => {
      return getUserFriends(user.id);
    })
    .then(friends => {
      // More chains possible
    }) ;
}

Normalization / Receive Example

Redux Ask is built out to allow receiving and normalizing entities easy! We should create an example to show users how to do this and how this should be done (in the onSuccess handler).

It's important this is done within the onSuccess handler so the success flag does not get set until receiving / normalization is complete.

createRequest(id => ({
  url: `/users/${id}`,
  method: 'GET',
  onSuccess: user => dispatch => {
    const normalized = normalizeUser(user);
    dispatch(receiveEntities(normalized));
  },
}));

Multiple Request Status Selectors

We should provide a helper selector to determine the status of multiple selectors. This will make it easy to gather a collection of different data.

I was thinking something along the lines of...

const mapStateToProps = state => {
  return {
    allSuccessful: allSuccessfulSelector(['REQUEST_1', 'REQUEST_2', 'REQUEST_3'])(state),
    anySuccessful: anySuccessfulSelector(['REQUEST_1', 'REQUEST_2', 'REQUEST_3'])(state),
  }
}

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.