• product technical lead at Myplanet ◦ past: TMX, health/pharma, large social sites • backend, frontend, server automation • 3D graphics, Android for fun • passionate about: ◦ UX ◦ lean enterprise ◦ empathy-driven engineering @unframework
learned Assembly before I learned English • how do things work, what makes them tick? • corollary: I bet I could make it too • indulge in tech, but also create value! ◦ startups = tech + marketing/evangelism ◦ sense of purpose, enhanced by empathy • amazing opportunities for hacking app ideas @unframework
on command-line • 1000s of useful packages ◦ https://www.npmjs.com/ • integrate with Slack, GitHub, Twilio, hardware (Tessel, Raspberry Pi), etc • great for quick hacks and trying integrations ◦ (also see Python, etc, as good alternatives) @unframework
from the browser • easily show data output, pictures • WebGL rendering • may deploy on e.g. Heroku, share URL • many hacks still use local hardware ◦ just a convenient output form @unframework
the UI to browser ◦ HTML ◦ CSS ◦ JS • define POST routes for interaction ◦ need jQuery to submit AJAX requests ◦ serialize/deserialize param strings • UI layout: Bootstrap? @unframework
of boilerplate to start • hard to modify as the prototype pivots • existing workflow is for websites! ◦ no need to worry about security, scalability, responsive layout, etc • can I haz quick hack pls? @unframework
standard AJAX is over-engineered ◦ all we need here is simple function calls • defining the UI itself ◦ ugh, CSS = WTF ◦ need the simplicity of reactive display render ◦ absolute-positioned layouts are OK • client-side URL routes (location hash) ◦ not so common, but still fun to consider! @unframework
not considered REST-ful ◦ roots in enterprisey SOA blah blah • but we don’t need much • transparently call functions, pass values ◦ HTTP? what’s that? • possibility of two-way communication ◦ aka “server push” @unframework
◦ needed GitHub API token access via server • using WebSockets! • just opens a WS connection and maps server functions to messages ◦ think “tunnel” for function calls @unframework
• automagically runs a web server ◦ client code is given a blank page ◦ exported server code is already hooked up ◦ just require(‘__server’) • usually Browserified, but can work as global • network is async: using Promises to remote method responses @unframework
block, just invoke callbacks when data is ready ◦ “callback hell” = when several sequential ops, resulting in a nested ladder of callbacks • Promise = immediate placeholder for future value ◦ collect the results by calling “then(callback)” ◦ allows chaining, error handling, ES7 async/await @unframework
and flexible communication • remote-control module does the grunt work ◦ serving up blank page with client code ◦ wiring up server methods in browser ◦ wraps every call in a Promise to track async completion @unframework
◦ no long-form flowing NYT editorial layouts ◦ no scrolling (99% of cases) • canvas 2D draw? ◦ straightforward… but needs buttons/text-fields • just use absolute CSS layouts ◦ top, left, width, height ◦ inline style because each part is a one-off • code is still kind of verbose @unframework
games ◦ just “cheap” 2D positioning without canvas • basic built-in styling • basic primitives like images, text and buttons • can always add custom HTML ◦ just rely on position:absolute • reactive rendering based on virtual DOM @unframework
wow • coding UI display is hairy ◦ create DOM elements, style them ◦ but, underlying model changes ◦ need to update displayed DOM elements ◦ managing incremental deltas = teh worst • need to simplify (especially for prototypes) @unframework
UI display stateless! • game engine analogy ◦ each frame is rendered, then trashed ◦ 16ms later (at 60fps), rinse and repeat ◦ DOM, styling = intermediate steps for browser “final picture” ◦ rebuild DOM tree every time, instead of updating ◦ DOM is slow to just trash, so use virtual DOM @unframework
render = new DOM tree from scratch ◦ actually, lightweight “blueprint” - virtual DOM ◦ the virtual-dom module then translates to “slow” real DOM for display • but when to redraw? ◦ observables? digest loop? ◦ setInterval(render, 10)? ◦ when do interesting things happen? listen to events! @unframework
when something new happens! ◦ mouse clicks, mouse moves, keyboard, view resize ◦ timer events, AJAX requests ◦ WebSocket traffic (i.e. our RPC) • early versions listened on document events • now using zone.js to intercept everything ◦ when anything happens, just redraw screen! ◦ simple and cheap! (don’t try this in production, yet) @unframework
“repaint” callback • use Boxbits chained API to draw boxes, buttons, etc ◦ produces a basic mobile-friendly fixed screen ◦ can still inject custom HTML (e.g. webcam display, etc) • that’s it for UI, can get back to hacking @unframework
◦ don’t want to lose client state, network connections • not so common for prototype UIs ◦ still nice to have ◦ especially when using as landing page for e.g. OAuth • simplest case: location hash @unframework
as path • routes = simple trackers/listeners for specific path pattern • if path = “#/setup”, then active = true ◦ can check status at any point, even during render ◦ can run callback when path is visited ◦ track when path is no longer active = whenDestroyed Promise • path params, declarative, local @unframework