tonyhb / tectonic

A declarative REST data loader for React and Redux. Docs @
https://tonyhb.github.io/tectonic/
456 stars 31 forks source link

Add `mutate` to Query model #26

Open tonyhb opened 8 years ago

tonyhb commented 8 years ago

mutate will mutate data before being passed into the component:

@load({
  users: User.getList().mutate(users => {
    const byId = {};
    users.forEach(u => byId[u.id] = u);
    return byId;
  }),
})
class Users extends Component {
}

Each mutator can be kept in a separate file for reusability. We should let mutator functions chain to keep composability of mutator functions optimal. Can we also automatically memoize these functions, or store the resulting data in a reducer?