isomorphic web apps with rum by nikita prokopov moscow
play

Isomorphic web apps with Rum by Nikita Prokopov MOSCOW NOVOSIBIRSK - PowerPoint PPT Presentation

Isomorphic web apps with Rum by Nikita Prokopov MOSCOW NOVOSIBIRSK not existing 1985 not programming 2001 studying programming 2005 not programming Clojure :( 2012 programming Clojure 2015 programming ClojureScript 2016 speaking at


  1. Isomorphic web apps with Rum by Nikita Prokopov

  2. MOSCOW NOVOSIBIRSK

  3. not existing 1985 not programming 2001 studying programming 2005 not programming Clojure :( 2012 programming Clojure 2015 programming ClojureScript 2016 speaking at ClojuTRE (we’re here)

  4. HISTORY

  5. React May 2013

  6. React Om May Dec 2013 2013

  7. Om Centralized state atom Asynchronous rendering Leveraged immutability

  8. React Om Reagent May Jan 2013 2014

  9. Reagent Reactive atoms Hiccup syntax

  10. React Om Reagent Quiescent May Feb 2013 2014

  11. Quiescent Minimal No state model Pure functional, no OOP

  12. React Om Rum Reagent Quiescent May Jan Dec 2013 2014 2014

  13. React Om Rum Om.Next Hoplon Reagent Freactive re-frame foam Quiescent Pump May Jan Dec July Nov 2013 2014 2014 2015

  14. IDEA

  15. Rum motivation Borrow all the good stuff Mix Om, Reagent, Quiescent models Be compatible with DataScript

  16. Rum motivation Borrow all the good stuff Mix Om, Reagent, Quiescent and other models Be compatible with DataScript any storage Be future-proof

  17. Solution Not opinionated Don’t commit to anything Build for extension

  18. Library, not a framework No mandatory state model Open, decomplected architecture Well-defined internals are treated as API Clear Rum/React mapping, escape hatches Minimal code base (~900 LOC)

  19. IMPLEMENTATION

  20. ( rum/defc label [text class] [:div.lbl {:class class} text]) (rum/mount (label "Hello" "header") js/document.body)

  21. Simpler than React functions, not classes arguments, not props no this (duh) DOM as data

  22. (def mixin { :will-mount (fn [ state ] (assoc state :key (atom nil))) }) (rum/defc label < mixin [text class] [:div.label {:class class} text])

  23. State is immutable lifecycle methods are pure can’t update component directly can’t close over a thing that will later change

  24. Mixins Pure, composable, no methods Powerful & decomplected: – Update logic defined per-component – Emulate Reagent, Quiescent/PureComponent, Om – Local state is a mixin

  25. SERVER-SIDE

  26. rum/defc Hiccup Ŝ ablono React.createElement VDOM React.js DOM

  27. (rum/defc label [text] [:.label text]) React.createClass({ render: function() { return React.createElement("div", { class: "label" }, this.props.text); } });

  28. rum/defc Hiccup rum/defc Hiccup Ŝ ablono Rum React.createElement VDOM React.js DOM Markup HTML

  29. (rum/defc label [text] [:.label text]) (defn label [text] (str "<div class='label'>" text "</div>"))

  30. Server-side rendering Renders to a string Use same components via CLJC 3 × faster than Hiccup in interpreting mode No state, no lifecycle Compatible with React.js server-side renderer

  31. CONCLUSION

  32. What’s Rum good for? Complex single-page apps with fine control Custom/mixed state models Server-side rendering and templating

  33. What’s Rum bad for? Doesn’t teach you how to write apps

  34. Contacts github.com/tonsky/rum #tonsky/rum at gitter.im #rum at clojurians.slack.com @nikitonsky

Recommend


More recommend