Skip to content

Instantly share code, notes, and snippets.

@mydea
Forked from machty/controllers.application.js
Last active March 12, 2019 11:17
Show Gist options
  • Save mydea/040c01c637dc2f036c237a3c38ab46ce to your computer and use it in GitHub Desktop.
Save mydea/040c01c637dc2f036c237a3c38ab46ce to your computer and use it in GitHub Desktop.
New Twiddle
import JSONAPIAdapter from 'ember-data/adapters/json-api';
import AdapterFetch from 'ember-fetch/mixins/adapter-fetch';
export default JSONAPIAdapter.extend(AdapterFetch, {
ajax() {
let promise = this._super(...arguments);
promise.finally(() => console.log('done'));
return promise;
},
});
import Ember from 'ember';
import { task, timeout, waitForProperty } from 'ember-concurrency';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
lol: false,
foo: task(function * () {
let { store } = this;
let model = store.createRecord('test-model');
try {
yield model.save();
} catch(error) {
console.log('ERROR', error);
throw error;
}
console.log('DONE');
}),
actions: {
setLolToTrue() {
this.set('lol', Math.random());
}
}
});
import Model from 'ember-data/model';
export default Model.extend({
});
<h1>Welcome to ember-concurrency</h1>
<p>
Use this twiddle as a jumping off point for your ember-concurrency
experiments / bug reports.
</p>
<p>
<button onclick={{perform foo}}>
Perform foo
</button><br>
</p>
<p>
state: {{foo.state}}<br>
last.value: {{foo.last.value}}
</p>
<p>
<button onclick={{action 'setLolToTrue'}}>
Set Lol to true
</button>
</p>
{
"version": "0.15.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js",
"ember": "3.4.3",
"ember-template-compiler": "3.4.3",
"ember-testing": "3.4.3"
},
"addons": {
"ember-data": "3.4.2",
"ember-concurrency": "0.8.27",
"ember-fetch": "latest"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment