Ideas taken from React • Declarative - predictable & easier to debug. • Everything is a Component - Proper separation of concerns. • Learn Once Write Anywhere - how to render is handled by library. 24
Mindset 1. Always re-render when data change. 2. Component returns a blueprint instead of the actual instance of UI. 3. Framework do the hard work to generate minimal UI updates. 28
Client-side rendering • initial request loads the page layout, CSS and JavaScript. • some or all of the content isn't included Server-side rendering • initial request loads the page, layout, CSS, JavaScript • and content. 42
Current Problems 1. Component state could not be preserved 2. Side-effects to make a meaningful first mount must be handled at the top level. 3. JS Runtime is required (e.g. V8, Nashorn.) 44
Marshal class Foo attr_reader :bar def initialize @bar = "yeah" end end f = Foo.new s = Marshal.dump(f) # => "\x04\bo:\bFoo\x06:\t@barI\"\tyeah\x06:\x06ET" f = Marshal.load(s) f.bar # => "yeah" 47
Marshal • Serialize object to byte stream. • Supported by almost every Rubies (e.g. Opal, MRI, RubyMotion.) • Almost everything could be marshaled by default. 48