Just sketching out some scenarios and how we would handle them with the tools we have in cerebral today (factories and actions).
State store:
Model({
messages: [
var baobab = new Baobab({ | |
todos: [{id: 1, title: 'boo'}, {id: 2, title: 'boo'}], | |
currentUser: { first_name: 'boo'} | |
}); | |
// unsetting (deleting) by query | |
setWhere('todos', {title: 'boo'}); // unsets any object with title 'boo' | |
setWhere('currentUser', {first_name: 'boo'}); // if the object's first name is 'boo' sets currentUser to null | |
//setting by query |
import Ember from 'ember'; | |
import Changeset from 'ember-changeset'; | |
export default Ember.Controller.extend({ | |
init() { | |
this._super(...arguments); | |
this.get('store').createRecord('foo', { | |
users: [ | |
this.get('store').createRecord('user', {name: 'bob'}), |
{ | |
"presets": [ | |
["env", { | |
"targets": { | |
"browsers": ["chrome 58"] | |
}, | |
"modules": false | |
}] | |
], | |
"plugins": [ |
import DS from 'ember-data'; | |
export default DS.RESTAdapter.extend({ | |
host: 'https://jsonplaceholder.typicode.com' | |
}); |
Adopting a convention usually means eliminating inconsequential choices or, in the event that there are two or more viable options, picking one as the blessed path. Ember was launched in a much different environment than today and it made some excellent choices by:
Building missing language and platform features like the Ember object/class model, Ember.Enumerable and utils, RSVP, Backburner.js, and even ember addons
Rallying around one choice in a crowded and chaotic ecosystem, like broccoli.js, testem/qunit, JSON-API, and ember-cli.
But, as the JS ecosystem has matured, many of those initial choices are simply not needed or the community has embraced other solutions.
import Ember from 'ember'; | |
import { task } from 'ember-concurrency'; | |
function* fetchStuff() { | |
console.log('In fetchStuff'); | |
yield fetchMoreStuffGeneratorFn(); | |
// fetchMoreStuff(); | |
} | |
function* fetchMoreStuffGeneratorFn() { |