Skip to content

Instantly share code, notes, and snippets.

@bfitch
bfitch / controllers.application.js
Last active March 11, 2019 18:35
nested generators
import Ember from 'ember';
import { task } from 'ember-concurrency';
function* fetchStuff() {
console.log('In fetchStuff');
yield fetchMoreStuffGeneratorFn();
// fetchMoreStuff();
}
function* fetchMoreStuffGeneratorFn() {
@bfitch
bfitch / embrace_the_javascript_ecosystem.md
Created May 4, 2018 18:42
#EmberJS2018: Embrace the Javascript Ecosystem

#EmberJS2018: Embrace the Javascript Ecosystem

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:

  1. Building missing language and platform features like the Ember object/class model, Ember.Enumerable and utils, RSVP, Backburner.js, and even ember addons

  2. 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 DS from 'ember-data';
export default DS.RESTAdapter.extend({
host: 'https://jsonplaceholder.typicode.com'
});
@bfitch
bfitch / .babelrc
Created June 1, 2017 15:51
Cherry picking uniq with babel-plugin-lodash
{
"presets": [
["env", {
"targets": {
"browsers": ["chrome 58"]
},
"modules": false
}]
],
"plugins": [
@bfitch
bfitch / controllers.application.js
Created November 21, 2016 01:32
Rollback Changeset hasMany
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'}),
@bfitch
bfitch / gist:6210ef18e98afa284b769a98bd3031c2
Created August 9, 2016 17:01
Caching HTTP requests with Factories

Caching HTTP requests with Factories

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
@bfitch
bfitch / esnextbin.md
Last active March 10, 2016 03:19
esnextbin sketch
@bfitch
bfitch / esnextbin.md
Created February 17, 2016 18:16
esnextbin sketch
@bfitch
bfitch / esnextbin.md
Last active February 17, 2016 05:02
esnextbin sketch