Skip to content

Instantly share code, notes, and snippets.

View jamesarosen's full-sized avatar

James A Rosen jamesarosen

View GitHub Profile
@jamesarosen
jamesarosen / components.delete-blog.js
Created November 18, 2016 20:03
passing-deferreds-down
import Ember from 'ember';
export default Ember.Component.extend({
classNames: [ 'delete-blog' ],
sudoDeferred: null,
isDone: false,
isWorking: false,
message: null,
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
@jamesarosen
jamesarosen / ember-context.md
Created September 13, 2016 22:42
Playing with an idea for Contexts for Ember Objects

Impetus

I have several components that have complex flows. For example, a "deploy this code" button. It might have the following flow:

  1. if the user is typing, the button is hidden
  2. after the user stops typing, the button appears, is disabled, and reads "Saving..."
  3. after the code is saved, the button is enabled and reads "Test & Deploy"
  4. after the user clicks the button, it is disabled and reads "Testing..."
  5. if the tests fail, the button remains disabled and reads "Tests Failed"
  6. if the tests pass, the button remains disabled and reads "Deploying..."
@jamesarosen
jamesarosen / ember-blocking-field.md
Last active September 9, 2016 19:37
A discussion of fields and forms in Ember

I have a form with three fields: Foo, Bar, Baz. Bar is really sensitive, so if the user changes it, I want to show a confirmation modal when the user tries to submit the form (but not until then). Currently, we have the is-bar-changed and show-modal logic in the containing form. I'd prefer to move it down into a component:edit-bar. But I can't figure out a good way to model that component having an opportunity to pause the parent form's submission, then continue or abort asynchronously.

Pass Down Hook Registry

One option would be for the form to yield some sort of hook registry:

@jamesarosen
jamesarosen / on-css.md
Last active November 13, 2018 15:47
On CSS

I don't have a Grand Vision for (S)CSS, but I do have some ideas.

Cohesion & Coupling

In JavaScript (and any other "programming language"), we value cohesion and eschew coupling. To value cohesion is to say that all of the foo-related things are in the Foo component or the app/pods/foo pod or the lib/foo addon. Like things are together. To eschew coupling is to say that two unrelated things should not need to know about one another. Unlike things don't rely on one another. Further reading on Cohesion & Coupling:

import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
import Ember from 'ember';
export default Ember.Component.extend({
tagName: 'section',
classNames: [ 'i18n-demo' ],
i18n: Ember.inject.service(),
beenClicked: false,
text: Ember.computed('i18n.locale', function()
{
@jamesarosen
jamesarosen / sproutcore-notes.md
Created July 1, 2016 06:07
Some notes I just found on SproutCore

After my recent move, I've been sorting through old papers. I just found this page of notes I had prepared before meeting @wycats and @tomdale for lunch to discuss SproutCore vs Backbone. It's undated, but from around March 2011.

I remember very vividly the passion they showed over that meal. They knew they had a long road ahead of them to convince the web-developer community of the value of this framework and that many substantial changes would be needed. But they had a vision and a group of people that were willing to give them a chance.

  • why #getEach instead of #pluck?
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});