Skip to content

Instantly share code, notes, and snippets.

@svschannak
Created May 10, 2017 12:48
Show Gist options
  • Save svschannak/64fd9fbfeb728fddfb6365bf4cc9069b to your computer and use it in GitHub Desktop.
Save svschannak/64fd9fbfeb728fddfb6365bf4cc9069b to your computer and use it in GitHub Desktop.
Example of calling a parent function in JavaScript using private function names.
export function mainFunction() {
const returnFunction = function fetchFunction(dispatch) {
const fetchConfig = {
url: '/api/endpoint/',
httpMethod: 'get',
successStatusCode: 200,
successCallback: (res) => {
//execute if successful
},
errorCallback: (err) => {
// wait and try the function again
setTimeout(fetchFunction(dispatch), 500);
}
};
dispatchFetch(fetchConfig);
}
return (dispatch) => returnFunction(dispatch);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment