Created
May 19, 2015 17:42
-
-
Save slyder/a66848456b99987ade79 to your computer and use it in GitHub Desktop.
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
// express method | |
app.use(async function (req, res, next) { | |
try { | |
let flux = new Flux(); | |
var {HandlerComponent, state} = await AuxService.runReactRouter(reactRoutes, req.url); | |
await AuxService.performRouteHandlerStaticMethod(state.routes, 'routerWillRun', {state, flux, req}); | |
... | |
} | |
... | |
} | |
// app component | |
class App extends React.Component { | |
static async routerWillRun({flux, state, req}) { | |
await flux.getActions('session').getSession(req); | |
} | |
// rendering ... | |
} | |
// session actions | |
class SessionActions extends AppActions { | |
getSession(req) { | |
// using req object here to pass cookies | |
return this.apiGet('/api/session/get', req); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment