Last active
August 29, 2015 14:05
-
-
Save simenbrekken/87f78f8dfd44f0b6bd63 to your computer and use it in GitHub Desktop.
Flux Server Initialization
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
| var categories = new Promise(function(resolve, reject) { | |
| var onChange = function() { | |
| CategoryStore.removeChangeListener('change', onChange) | |
| resolve(CategoryStore.getAll()) | |
| } | |
| CategoryStore.addChangeListener('change', onChange) | |
| CategoryActions.loadAll() | |
| }) | |
| var products = new Promise(function(resolve, reject) { | |
| categories.then(function() { | |
| var category = CategoryStore.get(params.categoryId) | |
| var onChange = function() { | |
| ProductStore.removeChangeListener('change', onChange) | |
| resolve(ProductStore.getAllForCurrentCategory()) | |
| } | |
| ProductStore.addChangeListener('change', onChange) | |
| ProductActions.loadCategory(category.id) | |
| }) | |
| }) | |
| Promise.props({ | |
| categories: categories, | |
| products: products | |
| }).then(function(data) { | |
| res.render('index', {data: data}) | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment