Skip to content

Instantly share code, notes, and snippets.

@isavch
Created December 15, 2017 13:49
Show Gist options
  • Select an option

  • Save isavch/a2ff360c9360391720476d6350038c62 to your computer and use it in GitHub Desktop.

Select an option

Save isavch/a2ff360c9360391720476d6350038c62 to your computer and use it in GitHub Desktop.
SS API
/* API usage */
import makeApi from 'redux-wp';
const api = makeApi(store);
api.getPost(2, 'posts')
.then(post => console.log(post));
/* Implementation */
import getPost from getPost
function makeApi(store) {
return {
getPost: getPost(store)
};
}
/* getPost.js */
function getPost(store) {
return (id, type) => {
return new Promise((resolve, reject) => {
/* Select data from store
if doesn't exist make a call
*/
});
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment