server.get('api/employee's, function(schema, request) {
employee = schema.employee.find(1);
this.serializerOrRegistry.serialize(employee, request);
return foo;
});| import Ember from 'ember'; | |
| export default Ember.Component.extend({ | |
| selected: {name: 'All', id:0}, | |
| computedOptions: Ember.computed('options.[]', function(){ | |
| return this.get('options').slice().insertAt(0, this.get('selected')); | |
| }) | |
| }); |
| import Ember from 'ember'; | |
| export default Ember.Component.extend({ | |
| tagName: '' | |
| }); |
| import Ember from 'ember'; | |
| export default Ember.Component.extend({ | |
| }); |
| import Ember from 'ember'; | |
| import { moduleFor, test } from 'ember-qunit'; | |
| let mockSession = Ember.Service.extend({ | |
| isAuthenticated: true, | |
| currentUser: Ember.computed('isAuthenticated', function() { | |
| return Ember.RSVP.Promise(function(resolve) { | |
| resolve( Ember.Object.create({ accounts: [] }) ); | |
| }); | |
| }) |
| import Ember from 'ember'; | |
| export default Ember.Controller.extend({ | |
| }) |
| import Ember from 'ember'; | |
| import PSOptionsComponent from 'ember-power-select/components/power-select/options'; | |
| const { | |
| $, | |
| assert, | |
| get, | |
| } = Ember; |
| // Determine if an element is in the visible viewport | |
| function isInViewport(element) { | |
| var rect = element.getBoundingClientRect(); | |
| var html = document.documentElement; | |
| return ( | |
| rect.top >= 0 && | |
| rect.left >= 0 && | |
| rect.bottom <= (window.innerHeight || html.clientHeight) && | |
| rect.right <= (window.innerWidth || html.clientWidth) | |
| ); |
While attempting to explain JavaScript's reduce method on arrays, conceptually, I came up with the following - hopefully it's helpful; happy to tweak it if anyone has suggestions.
JavaScript Arrays have lots of built in methods on their prototype. Some of them mutate - ie, they change the underlying array in-place. Luckily, most of them do not - they instead return an entirely distinct array. Since arrays are conceptually a contiguous list of items, it helps code clarity and maintainability a lot to be able to operate on them in a "functional" way. (I'll also insist on referring to an array as a "list" - although in some languages, List is a native data type, in JS and this post, I'm referring to the concept. Everywhere I use the word "list" you can assume I'm talking about a JS Array) This means, to perform a single operation on the list as a whole ("atomically"), and to return a new list - thus making it much simpler to think about both the old list and the new one, what they contain, and
| import Ember from 'ember'; | |
| export { dirtyHasMany, dirtyBelongsTo, dirtyMixin }; | |
| var dirty = 'relationshipIsDirty'; | |
| function dirtyMixin (obj) { | |
| var args = Object.keys(obj); | |
| var comp = Ember.computed; | |
| args.push('isDirty'); | |
| obj[dirty] = comp.any.apply(comp, args); |