Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Experience in building isomorphic app

Experience in building isomorphic app

How to build an isomorphic app.
Present in reactjs.tw 3rd party @CLBC flagship
Demo: http://2014final.wethepeople.tw

Yuanhsiang Cheng

December 18, 2014
Tweet

More Decks by Yuanhsiang Cheng

Other Decks in Technology

Transcript

  1. Database Routing Controller View DOM / AJAX / UX Client

    Server JS PHP Ruby Python Java Server-side render
  2. Database Routing Controller View DOM / AJAX / UX Client

    Server JS PHP Ruby Python Java Client-side render
  3. Database Routing Controller View DOM / AJAX / UX Client

    Server JS PHP Ruby Python Java Isomorphic render
  4. Isomorphic render flow Low latency and UX is like SPA

    Download
 Full HTML Download
 Javascript Evaluate
 Javascript Fetch
 Data
  5. Directory Structure client/ server/ src/ styles/ scripts/ webpack.config.js api/ render/

    server.js components/ pages/ stores/ app.js app_router.js images, fonts, css files api - use Mongo
 render - require(‘../src/app_router’) reactjs & flux
  6. Server-side Render Add server/ api.js render.js Router.renderRoutesToString(router, path, function (output)

    {
 var html = template.replace($BODY, output);
 … replace title, description …
 res.send(html);
 }); react-router 0.10.2
  7. Superagent same as server and client getQuestions ( query, cb)

    {
 request
 .get(makeURL(‘/questions’)
 .query(query)
 .timeout(TIMEOUT)
 .end(function ( err, res) { 
 … deal res …
 });
 }
  8. What I Learn components vs pages angularjs to reactjs workflow

    :p environment vars e.g. req.path / window.location.pathname req.header / document.cookie