Last active
April 21, 2020 12:14
-
-
Save jenweber/7765753fe8715adbdb0c7675fe7f17d7 to your computer and use it in GitHub Desktop.
ember-concurrency demo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
import { task, timeout } from 'ember-concurrency'; | |
export default Ember.Component.extend({ | |
notify: Ember.inject.service('notify'), | |
actions: { | |
startECLoop: function() { | |
this.get('emberConcurrencyLoop').perform(); | |
}, | |
notUsingECLoop: function() { | |
this.get('notify').info('NOT using ember-concurrency', { | |
classNames: ['not-using-ec'] | |
}) | |
setInterval(function(){ | |
this.get('notify').info('NOT using ember-concurrency', { | |
classNames: ['not-using-ec'] | |
}) | |
}.bind(this), 3000); | |
}, | |
clickEC: function() { this.get('emberConcurrencyEvent').perform() | |
}, | |
clickRegular: function() { | |
this.get('notify').info('NOT using ember-concurrency', { | |
classNames: ['not-using-ec'] | |
}) | |
} | |
}, | |
emberConcurrencyLoop: task(function * () { | |
while(true) { | |
this.get('notify').info('Yay, ember-concurrency task :)', { | |
classNames: ['using-ec'] | |
}) | |
yield timeout(3000) | |
} | |
}).drop(), | |
emberConcurrencyEvent: task(function * () { | |
this.get('notify').info('Yay, ember-concurrency task :)', { | |
classNames: ['using-ec'] | |
}) | |
yield timeout(3000) | |
}).drop(), | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Simple Ember Concurrency Demo', | |
init: function() { | |
this.transitionToRoute('with-concurrency'); | |
return this._super(...arguments); | |
}, | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
import config from './config/environment'; | |
const Router = Ember.Router.extend({ | |
location: 'none', | |
rootURL: config.rootURL | |
}); | |
Router.map(function() { | |
this.route('with-concurrency'); | |
this.route('home'); | |
}); | |
export default Router; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Route.extend({ | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Route.extend({ | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
margin: 12px 16px; | |
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; | |
font-size: 16pt; | |
} | |
.not-using-ec { | |
background-color: lightsalmon; | |
font-weight: bold; | |
} | |
.using-ec { | |
background-color: lightskyblue; | |
font-weight: bold; | |
} | |
button { | |
font-size:16px; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.12.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.12.0", | |
"ember-template-compiler": "2.12.0", | |
"ember-testing": "2.12.0" | |
}, | |
"addons": { | |
"ember-data": "2.12.1", | |
"ember-concurrency": "0.8.3", | |
"ember-notify":"5.2.1" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment