Skip to content

Instantly share code, notes, and snippets.

🍊
Working remotely

Bill Heaton pixelhandler

Block or report user

Report or block pixelhandler

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@pixelhandler
pixelhandler / gist:d773fb3cfcf1a345014d75e43da65b77
Created Jan 15, 2019
JavaScript Generators and Concurrency
View gist:d773fb3cfcf1a345014d75e43da65b77
# JavaScript Generators and Concurrency
1. Why generators are a nice fit for handling a coroutine (source/sink)
2. How we use generators in the Dashboard app
3. What generators can do to help wrangle async behavior
Generators are functions that can be paused and resumed (think cooperative multitasking or coroutines)
Pitch:
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
someVal: 5
});
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
View controllers.application.js
import { computed, defineProperty } from '@ember/object';
import { later } from '@ember/runloop';
export default Ember.Controller.extend({
init() {
later(() => {
defineProperty(this, 'delayedProperty', computed(() => 'foo'));
this.notifyPropertyChange('delayedProperty');
}, 2000);
},
View components.test-component.js
import Ember from 'ember';
import { computed, get } from '@ember/object';
export default Ember.Component.extend({
baz: computed('foo', {
get() {
alert(get(this, 'foo'));
}
})
});
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
count: 4,
rawCount: 4,
actions: {
update(value) {
if (value > 999) {
this.set('count', 999);
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
// Broken on 2.10.2
// Works as expected on 2.9.1
@pixelhandler
pixelhandler / controllers.application.js
Last active Oct 12, 2018 — forked from dwickern/controllers.application.js
#15545 Ember.cacheFor + aliased property
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName: '#15545',
aliased: Ember.computed.alias('appName'),
init() {
this._super(...arguments);
console.log('before:', this.cacheFor('aliased'));
console.log('get:', this.get('aliased'));
@pixelhandler
pixelhandler / controllers.application.js
Last active Oct 12, 2018 — forked from mjuniper/controllers.application.js
Error route model with reject from model hook
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'https://github.com/emberjs/ember.js/issues/15842'
});
View components.my-component.js
import Ember from 'ember';
export default Ember.Component.extend({
// Comment out below to work around
target: 'body',
actions: {
buttonClick() {
this.sendAction('onClick');
}
You can’t perform that action at this time.