Skip to content

Commit

Permalink
If there are no optimistic updates to apply, return immediately.
Browse files Browse the repository at this point in the history
  • Loading branch information
dahjelle committed Aug 29, 2016
1 parent 3c9e4ce commit 4e222ba
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Expect active development and potentially significant breaking changes in the `0

### vNEXT

- Avoid extra `assign` when there are no optimistic updates present. [PR #597]((https://github.com/apollostack/apollo-client/pull/597)
- ...

### v0.4.13
Expand Down
3 changes: 3 additions & 0 deletions src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ export interface ApolloReducerConfig {
}

export function getDataWithOptimisticResults(store: Store): NormalizedCache {
if (store.optimistic.length === 0) {
return store.data;
}
const patches = store.optimistic.map(opt => opt.data);
return assign({}, store.data, ...patches) as NormalizedCache;
}

0 comments on commit 4e222ba

Please sign in to comment.