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

Immutability is for UI, You and I

Immutability is for UI, You and I

Charles Lowell

March 30, 2016

Transcript

97 slides
  1. gateway drug •Powerful view system (for the time) •Crazy Powerful

    Router •Layered Decoration of Models •Community with shared values
  2. A Form Library • progressive field revelation • local and

    remote validations • checklist validations (e.g. password rules) • validation dependencies • overall progress and percentage completion • dirty checking and wholistic submit button enabling • autobuffering of source objects • integrated with submission process (isSubmitting) ambitious ^ n
  3. TypeError: Cannot read property '0' of null at firstKey (http://localhost:7357/assets/vendor.js:20674:35)

    at ChainNodePrototype.chain (http://localhost:7357/assets/vendor.js:20907:15) at ChainNodePrototype.chain (http://localhost:7357/assets/vendor.js:20909:14) at ChainNodePrototype.add (http://localhost:7357/assets/vendor.js:20861:12) at watchPath (http://localhost:7357/assets/vendor.js:29357:27) at watch (http://localhost:7357/assets/vendor.js:29415:9) at addDependentKeys (http://localhost:7357/assets/vendor.js:22657:9) at Descriptor.AliasedProperty.willWatch (http://localhost:7357/assets/vendor.js:19928:7) at watchKey (http://localhost:7357/assets/vendor.js:29249:44) at watch (http://localhost:7357/assets/vendor.js:29413:9) at addObserver (http://localhost:7357/assets/vendor.js:25847:7) at Object.merge.valueFn (http://localhost:7357/assets/vendor.js:49708:13) at Object.Stream.value (http://localhost:7357/assets/vendor.js:27932:36) at read (http://localhost:7357/assets/vendor.js:28171:23) at Object.merge.valueFn (http://localhost:7357/assets/vendor.js:27835:16) Et tu, CP?
  4. {{input type="password" action=(action "setPassword")}}
 <ul> 
 <li>{{input type="checkbox" checked=longEnough}} Long

    Enough?</li>
 <li>Rating: {{rating}}</li>
 </ul> {{input type="password" action=(action "setPassword")}}
 <ul> Password
 <li>{{input type="checkbox" checked=model.longEnough}} Long Enough?</li>
 <li>Rating: {{model.rating}}</li>
 </ul> Extract
  5. actions: { 
 setPassword(text) {
 this.set('model.password', text);
 }
 } actions:

    {
 setPassword(text) {
 this.set('model', new PasswordForm({
 password: text
 }));
 }
 } Replace
  6. { password: “”, longEnough: false, rating: “weak” } Password Form

    The Movie Opening Summer 2016 <password-form/> { password: “$$/l33t”, longEnough: true, rating: “moderate” } { password: “l33t”, longEnough: true, rating: “weak” }
  7. POJO: feels so good Back to Basics class PasswordForm {


    get longEnough() {
 return this.text.length >= 4;
 }
 }
  8. { password: “”, longEnough: false, rating: “weak” } Password Form

    The Movie Opening Summer 2016 <password-form/> { password: “$$/l33t”, longEnough: true, rating: “moderate” } { password: “l33t”, longEnough: true, rating: “weak” } Undo/Redo
  9. Content / Player 1. Extract The Model into Its Own

    Object 2. Replace The entire model with each change Immutable Today

More Decks by Charles Lowell

Other Decks in Programming