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

Isomorphic Apps

Isomorphic Apps

A brief about how isomorphic apps should work

Nicolas Escalante

September 29, 2016
Tweet

Other Decks in Programming

Transcript

  1. Isomorphic Apps or how we share our code between the

    server and the client npm install nescalante
  2. Goals • UI should load fast • Once loaded, the

    interaction should be even faster • All the above should be easy to maintain
  3. UI should load fast • We can’t wait for Javascript

    to load • The content should come on the first request • The content should come from the server
  4. In some kind of pseudo code onActionTriggered(action) { // http

    req // model var state = getState(action) // HTML var view = getView(state) render(view) } a function!
  5. We can’t wait for Javascript to load • We don’t

    need it at all • We can live without it • We save considerable time
  6. Once loaded, interactions should be even faster • From now

    on, only data is needed • The view functions should be already there • No more calls to the UI server
  7. In some kind of pseudo code onSearchChange(term) { url.change(‘?search=‘ +

    term) action = newSearch(term) triggerAction(action) } onActionTriggered(action) { var state = getState(action) var view = getView(state) render(view) } history change
  8. Isomorphic code // Action is triggered by url changes //

    or Http requests onActionTriggered(action) { // State is generated by // calls to the API var state = getState(action) // A function that returns HTML var view = getView(state) render(view) }
  9. Isomorphic warnings • Use polyfills to support what browsers don’t

    • Be careful about the libs that you pick • Test everything everywhere
  10. Isomorphic setup • Your code should be interpreted by the

    server • Your code should be interpreted by browsers • All that code should be the same
  11. UI should load fast • Serving the content without waiting

    for JS • Doing the render on the server
  12. Once loaded, should interact fast • Fetching only the data

    thats needed • The views are already in JS