Skip to content

Instantly share code, notes, and snippets.

View jasonmit's full-sized avatar
🌴
On a hiatus from open source

Jason Mitchell jasonmit

🌴
On a hiatus from open source
View GitHub Profile
const TaskInput = () => {
let [inputValue, setInputValue] = useState('');
let [perform, taskState] = useTask(function*(newInputValue) {
setInputValue(newInputValue);
yield timeout(1000);
if (newInputValue) {
return [newInputValue];
}
const TaskInput = () => {
let shouldPerform = useRef(false);
let [inputValue, setInputValue] = useState('');
let [perform, taskState] = useTask(function*() {
yield timeout(1000);
if (inputValue) {
return [`good ${inputValue}`, `better ${inputValue}`, `best ${inputValue}`];
}
@jasonmit
jasonmit / components.x-foo.js
Last active April 2, 2019 22:22
New Twiddle
import Ember from 'ember';
export default Ember.Component.extend({
});
@jasonmit
jasonmit / gist:9c5c1891cc7f808644fd067d24f1993d
Last active April 10, 2019 03:22
intecept prevent propagation + once() allows for tighter control over ordering request handlers
// Currently there is a gap in the API for supporting
// intecepting requests by specific order. An intercept()
// will call all intercept handlers registered against a route, in order.
// In some cases, you may want them to be order-specific. i.e.,
// fire an intercept, when the next time the route is hit fire another.
// It can be achieved today with the current API, but it requires
// a bit of boilerplate and isn't trivial for those who don't understand
// the inner-workings of the API (it trolled Alex, and I didn't know immediately what
// the stacking behavior would be without looking through the docs/implementation).
//
@jasonmit
jasonmit / persist-qps.js
Created March 13, 2019 20:20
Persisting query params
import { run } from '@ember/runloop';
import { action } from '@ember-decorators/object';
import storageFor from 'os-workflows/utils/storage-for-decorator';
const { assign } = Object;
export function withQueryParamMemory(Klass) {
return class WithQueryParams extends Klass {
@storageFor('route-memory')
_memory;
@jasonmit
jasonmit / tracker-data-provider-component.js
Last active March 7, 2019 21:46
Controlling flow of subscription backed model
import { run } from '@ember/runloop';
import Component from '@ember/component';
import { action } from '@ember-decorators/object';
import { task } from 'ember-concurrency-decorators';
import { argument } from '@ember-decorators/argument';
import { inject as service } from '@ember-decorators/service';
import { layout, tagName } from '@ember-decorators/component';
import { readOnly } from '@ember-decorators/object/computed';
import { shapeOf } from '@ember-decorators/argument/types';
import query from 'os-workflows/queries/fetch-tracker';
@jasonmit
jasonmit / controller.js
Created January 9, 2019 10:13
ember discuss question
import { task } from 'ember-concurrency';
export default Controller.extend({
setup: task(function*() {
yield delay(6000);
this.set('model', { message: '1' });
yield delay(4000);
this.set('model', { message: '2' });
@jasonmit
jasonmit / tracker.hbs
Last active December 11, 2018 09:10
Shared Task Containers
{{#each taskLists as |taskList|}}
<TaskList>
{{#each tasklist.tasks as |task|}}
{{!-- Same Container Component Types between the Read & Edit view --}}
{{#component (task-container-for task) as |c|}}
{{!-- ReadView is the current TaskComponent + read view of the Task Integration components --}}
{{c.TaskRead}}
{{/component}}
{{/each}}
</TaskList>
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
init() {
this._super(...arguments);
this.objects = [
{ label: 'First' },
function timeout(ms) {
return new Promise((resolve) => {
setTimeout(() => resolve(), ms);
});
}
function blockCard(cardElement) {
const bio = cardElement.querySelector('.ProfileCard-bio');
const blockStatus = cardElement.querySelector('.blocked');