Skip to content

Instantly share code, notes, and snippets.

@jamesplease
Last active May 3, 2018 21:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamesplease/aad2638b5e90feaacc33c099de6464d4 to your computer and use it in GitHub Desktop.
Save jamesplease/aad2638b5e90feaacc33c099de6464d4 to your computer and use it in GitHub Desktop.
// Deep merge
update('resources.books', {
24: {
attributes: {
firstName: 'james'
}
}
});
// Do some shit
update('resources', {
books: { ... },
authors: { ... }
});
getResources('books', {team: 'red'});
getList('favoriteBooks');
<List name="favoriteBooks">
{() => {}}
</List>
<Resources type="books" filter={}>
{({ update }) => {
}}
</Resources>
update({
resources: {
books: [{}, {}],
authors: {
24: { ... }
}
},
lists: {
favorites: [{}, {}, {}]
}
});
update('resources.books.24.attributes.name', {
firstName: 'Stephen',
initial: 'R'
}, {merge: false});
remove('lists.favoriteBooks');
remove('lists.favoriteBooks', [2]);
function updateBooks(path, update) {
return store.update(`resources.books.${path}`, update);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment