Created
December 15, 2017 13:49
-
-
Save isavch/a2ff360c9360391720476d6350038c62 to your computer and use it in GitHub Desktop.
SS API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* 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