Last active
September 13, 2016 17:21
-
-
Save sminutoli/fc5d67571f0bc7a0b0a818a00c2b5713 to your computer and use it in GitHub Desktop.
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
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