Skip to content

Instantly share code, notes, and snippets.

@LevelbossMike
Last active March 9, 2017 09:46
Show Gist options
  • Select an option

  • Save LevelbossMike/4283805a7c716fb1acf24284ff0b9077 to your computer and use it in GitHub Desktop.

Select an option

Save LevelbossMike/4283805a7c716fb1acf24284ff0b9077 to your computer and use it in GitHub Desktop.
New Twiddle
import Ember from 'ember';
import { task, timeout } from 'ember-concurrency';
export default Ember.Component.extend({
didReceiveAttrs() {
this._super(...arguments);
let task = this.get('message.task');
this.get('closeTask').perform(task);
},
closeTask: task(function* (task) {
yield task;
yield timeout(1000)
this.get('close')();
})
});
import Ember from 'ember';
import { task, timeout } from 'ember-concurrency';
const { inject: { service } } = Ember;
export default Ember.Controller.extend({
notify: service(),
appName: 'Ember Twiddle',
testTask: task(function* () {
console.log('task started');
yield timeout(1000);
console.log('task complete');
}),
actions: {
notify() {
let testTask = this.get('testTask').perform();
this.get('notify').info({component: 'custom-notification', text: "alert", task: testTask});
},
notifyPlain() {
this.get('notify').info('simple text notification');
}
}
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
<button {{action 'notify'}}>Notify</button>
<button {{action 'notifyPlain'}}>Notify plain</button>
<br>
<br>
{{#ember-notify closeAfter=null as |message close|}}
{{#if message.component}}
{{component message.component message=message close=close}}
{{else}}
{{message.text}}
<button {{action close}}>Dismiss</button>
{{/if}}
{{/ember-notify}}
<div>
Custom Notification:
</div>
{{message.text}}
<div>Tasks is running: {{message.task.isRunning}}</div>
<button {{action close}}>Dismiss</button>
{
"version": "0.11.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.11.0",
"ember-data": "2.11.0",
"ember-template-compiler": "2.11.0",
"ember-testing": "2.11.0"
},
"addons": {
"ember-notify": "5.2.1",
"ember-concurrency": "0.7.19"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment