On Github iterion / molecule-ember
Adam Sunderland / @iterion
warn that I'm unabashedly using some rubyisms throughoutIssues/Limitations (for us)
Molecule.NotesFieldComponent = Em.Component.extend actions: toggleNotes: -> @toggleProperty('showNotes')
<div class="notes-label" {{action toggleNotes}}> {{yield}} </div> {{#if showNotes}} <div class="notes-body"> {{textarea value=notes}} </div> {{/if}}
{{#notes-field notes=trade.notes}} <i class="icon-file-text"></i> <span>Notes</span> {{/notes-field}}
Molecule.NotesFieldComponent = Em.Component.extend actions: toggleNotes: -> @toggleProperty('showNotes')
<div class="notes-label" {{action toggleNotes}}> {{yield}} </div> {{#if showNotes}} <div class="notes-body"> {{textarea value=notes}} </div> {{/if}}
{{#notes-field notes=trade.notes}} <i class="icon-file-text"></i> <span>Notes</span> {{/notes-field}}
Better code reuse throughout our app (we used the above in 3 different places and on two different models)
seems simple, but it's something we really just didn't have a easy way to accomplish in knockout knockout has binding handlers, but they didn't work wellself.productName = ko.computed(function () { if (self.product()) { return self.product().name; } });always null checking - mixing functions and properties
productName: function () { return this.get('product.name'); }.property('product.name')
productName: Ember.computed.alias 'product.name'
<span data-bind="text: productName"><span>
{{productName}}
Turns this:
http://molecule.io/trades
into
Routes are hierarchical
ApplicationRoute > TradesRoute > TradesIndexRoute
we can load things at each level of the route application route loads products & entitiesUsability win for SPA
allows our users to link directly to screens in our appReduced asset loading
we're not loading data unless we need to display itwow
much conventions
so confuse
?
?
?
ActiveModelSerializer in Ruby
DS.ActiveModelSerializer in Ember-Data
It just works
DS.ActiveModelSerializer is pretty new, previously we had to write our own serializers embedded document support is pretty newFind all trades
@store.find('trade')
trade by id
@store.find('trade', 1)
arbitrary query
@store.find('trade', {product: "Ethane"})
promises
@store.find('trade', 1).then (trade) -> #called after ajax finishes and model is created trade.get('price')
updates
trade.set('price', 25); trade.get('isDirty'); #true trade.save();
convention over configuration
opinionated
It was hard, but now it's much easier with ember-testing
No Ember "gems"
Limited libraries/components to use
Sometimes hard to integrate with existing stuff (bootstrap in particular is a pain)
ember routes with link-to sets an active class doesn't play well with dropdowns in bootstrapAdam Sunderland / @iterion
doge language consultant: Hana Wang / @hahahanahaha