Skip to content

Instantly share code, notes, and snippets.

@zandzpider
Created February 15, 2016 16:15
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 zandzpider/8cea9aa0130440b5a83a to your computer and use it in GitHub Desktop.
Save zandzpider/8cea9aa0130440b5a83a to your computer and use it in GitHub Desktop.
let translationsContainer = {
data : [],
promise : false,
load: function() {
return new Promise((resolve, reject) => {
if (this.promise) {
this.promise.then(() => {
resolve(this.data);
});
} else {
this.promise = Api.get("/api/translations").then((response) => {
this.data = response.data;
resolve(this.data);
});
}
});
}
};
// usage
translationsContainer.load().then((response) => {
// do things
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment