290 likes | 356 Views
Real World SPA. A Knockout Case Study. Cory House | bitnative.com | @housecor | speakerrate.com/talks/27181. Hi, I’m Cory. @ housecor. What monthly payment would you like?. JavaScript Configuration Object Pattern. Config Object Pattern: A justification. Separation of concerns
E N D
Real World SPA A Knockout Case Study Cory House | bitnative.com | @housecor | speakerrate.com/talks/27181
Hi, I’m Cory. @housecor
Config Object Pattern: A justification • Separation of concerns • Caching • Minimizes string parsing overhead • Code coloring • Syntax checking • Reusable • Reduced payload • Less abstraction • More at bitnative.com/2013/10/06/javascript-configuration-object-pattern/
Stay DRY by Mapping • http://jsfiddle.net/housecor/uAe3k
Databinding advantages • Discoverability • Clarity • Less Code – Separation of tightly bound concerns without a strong interface abstracts rather than clarifies.
Network Transport • AJAX • Go 2-way: • WebSocket • AJAX Long-polling • Adobe® Flash® Socket • AJAX multipart streaming • Forever Iframe • JSONP Polling • Or punt:
Service Layer • WebAPI
Cross Browser Testing XP-More Many options: http://bit.ly/16cXevo
Convention • Composition<div data-bind=“compose: ‘viewmodels/vehicle’></div> <!-- ko compose: ‘viewmodels/vehicle’ --><!-- /ko --> • Dependency Management • Routing
RequireJs • Utilizes AMD pattern • Dynamically load JS • Inject dependencies • Watch for circular dependencies
DOM Weight • Traditional: Every element is rendered on the server and thus on the client. • Client-side: Elements are rendered real-time as needed.
Why? • Responsive • Rich Interactivity • Separation of concerns • Efficient • Simple - Less abstraction • Debugging • No compile wait • Faster page load
Why not? • Proprietary business logic • Low interactivity • Slower page load • Page is rarely called • Complex – Too many choices! • Debugging pain • Runtime errors • Cryptic • One mistake and nothing loads
SPA Experience Complete • Back to the real world. • Cory House • bitnative.com • @housecor • speakerrate.com/talks/27181