Skip to content

Instantly share code, notes, and snippets.

@sminutoli
Last active September 13, 2016 17:21
Show Gist options
  • Save sminutoli/fc5d67571f0bc7a0b0a818a00c2b5713 to your computer and use it in GitHub Desktop.
Save sminutoli/fc5d67571f0bc7a0b0a818a00c2b5713 to your computer and use it in GitHub Desktop.
require('./API');
require('./CategoryList');
const App = {
selector: '#app',
fetchAPI: API,
run(){
this.fetchAPI
.categories()
.then(this.wrapCategories) //si la función no necesita a this, no hago un bind innecesario
.then(CategoryListFactory) //puedo usar directamente el factory, cosa imposible con class y new()
.then(this.renderHTML.bind(this));
},
wrapCategories(categoriesJSON){
return { categories: categoriesJSON };
},
renderHTML(anElement){
$(this.selector).html(anElement.toHTML());
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment