-
-
Save edjafarov/ef59240cc53f840bd68e to your computer and use it in GitHub Desktop.
the client file draft
This file contains 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 AppComp = React.createClass({ | |
render: function () { | |
return ( | |
<div className="container"> | |
The App | |
<RouteHandler/> | |
</div> | |
); | |
} | |
}); | |
var ItemComp = React.createClass({ | |
render: function () { | |
return ( | |
<div className="item"> | |
Item | |
</div> | |
); | |
} | |
}); | |
var ItemStore = BasicStoreFactory('ItemStore', { | |
item: null, | |
init: function(context){ | |
context.actions.on('got:item', this.gotItem.bind(this)); | |
}, | |
gotItem: function(item){ | |
this.item = item; | |
this.emit('change', this.item); | |
}, | |
get: function(){ | |
return this.item; | |
} | |
}); | |
var getItem = PromisePiper().get('/api/item').emit('got:item'); | |
var routes = <Route path="/" handler={AppComp}> | |
<Route name="item" path="item" handler = {ItemComp} action={getItem} stores={ItemStore}/> | |
</Route> | |
var appCfg = { | |
routes: routes | |
} | |
var app = createApp(appCfg); | |
module.exports = app; |
This file contains 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 express = require('express'); | |
var app = express(); | |
var client = require('client.js'); | |
app.use(client.middleware) |
@koorchik
пока состояние не передается, хотя это будет и будет просто приходить в сторы - это не проблема
сейчас оно дергает апи на серваке, все билдит в хтмл, потом делает тоже самое на клиенте - это удобно для дебага
Вместо диспатчера и экшнов будут использоваться цепочки реюзабельных промисов (PromisePipes)
http://eldar.djafarov.com/2015/01/the-holy-grail-promise-pipes/
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
А каким образом ты планируешь состояние стора передавать на клиент? По идее ж надо его сериализировать как-то на сервере, а затем десереализировать на клиенте. Есть уже реализованный client.middleware или это только задумка?
Также я так понял, что вместо диспатчера планируется использовать eventEmitter, но что с waitFor?