Skip to content

Instantly share code, notes, and snippets.

@theseyi
Forked from sukima/components.test-task.js
Created March 31, 2019 09:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theseyi/719c2bb392295ed363f9d7df4f3460d4 to your computer and use it in GitHub Desktop.
Save theseyi/719c2bb392295ed363f9d7df4f3460d4 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": {
"ember": "3.4.3",
"ember-template-compiler": "3.4.3",
"ember-testing": "3.4.3"
},
"addons": {
"ember-local-storage": "^1.7.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment