Created
September 13, 2016 14:58
-
-
Save sminutoli/ca9119e42e8cefdb5f18201beee0df25 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.addCategoriesToList.bind(this)) // cómo se puede preservar el this dentro de las promises? bluebird soporta un bind() pero parece que ES2015 no :( | |
.then(this.listToHTML.bind(this)) | |
.then(this.renderHTML.bind(this)); | |
}, | |
addCategoriesToList(categories){ | |
return CategoryList.from({ categories }); | |
}, | |
listToHTML(categoryList){ | |
return categoryList.toHTML(); | |
}, | |
renderHTML(html){ | |
$(this.selector).html(html); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment