Skip to content

Instantly share code, notes, and snippets.

@sukima
Last active March 31, 2019 09:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sukima/892e6ba71670742722c7f4bbc26423ef to your computer and use it in GitHub Desktop.
Save sukima/892e6ba71670742722c7f4bbc26423ef to your computer and use it in GitHub Desktop.
concurrency onerror
import Ember from 'ember';
import { task, timeout } from 'ember-concurrency';
export default Ember.Component.extend({
isRunning: Ember.computed.reads('theTask.isRunning'),
error: Ember.computed.reads('theTask.last.error'),
theTask: task(function* () {
console.count('task performed');
//yield timeout(1000);
throw new Error('bork');
}).drop()
});
import Ember from 'ember';
export function initialize() {
Ember.onerror = function(error) {
console.count('onerror');
//console.log(error);
};
}
export default {
name: 'custom-onerror',
initialize
};
<div class="hack container">
<TestTask/>
</div>
<button
class="btn btn-ghost btn-primary"
{{action (perform this.theTask)}}>
Go
</button>
{{#if this.isRunning}}
<div class="alert alert-info">
Loading&hellip;
<span class="loading"></span>
</div>
{{else if this.error}}
<div class="alert alert-error">{{this.error}}</div>
{{else}}
<div class="alert alert-success">Complete</div>
{{/if}}
{
"version": "0.15.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"hack_css": "https://cdnjs.cloudflare.com/ajax/libs/hack/0.8.1/hack.css",
"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-concurrency": "latest"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment