Skip to content

Instantly share code, notes, and snippets.

@averydev
averydev / controllers.application.js
Last active November 3, 2017 15:26
Listener test
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
on:false,
simpleOn:false,
actions:{
click(){
console.log("Click!");
},
import Ember from 'ember';
export default Ember.Component.extend({
tagName: 'button',
click(evt) {
console.log('x-button click', evt); // will be torn down
this.sendAction();
}
});
@averydev
averydev / controllers.application.js
Last active November 22, 2017 17:16
Ember Concurrency Task Model / Nested Routes
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Concurrency Decendants'
});
@averydev
averydev / route.js
Last active December 29, 2017 20:48
Async of Swim: basic case. Replace route with Ember Concurrency Task
// In your route...
import Route from '@ember/routing/route';
import { task } from 'ember-concurrency';
export default Route.extend({
model: function (){
return {
blog: this.get('blogTask').perform()
};
},
blogTask: task(function *(){
@averydev
averydev / route.js
Last active December 29, 2017 20:50
Async of Swim: Nested Routes. Replace route with Ember Concurrency Task
// routes/blog/comments.js
model: function (params){
return {
comments: this.get('commentsTask').perform()
};
},
commentsTask: task(function *(){
let blog = yield this.modelFor('blog').blogTask;
let comments = yield blog.get('comments');
return comments;
@averydev
averydev / route.js
Last active December 27, 2017 04:54
Async of Swim: Dynamic Segments.
//In your route
import Route from '@ember/routing/route';
import { task } from 'ember-concurrency';
export default Route.extend({
model: function (params){
return {
blog: this.get('blogTask').perform(params.blog_id)};
},
blog: task(function *(blogId){
let blog = yield this.get('store').findRecord('blog', blogId );
@averydev
averydev / route.js
Created December 24, 2017 19:26
Async Or Swim: Cancel Abandoned Model Calls
commentsTask: task(function *(){
let blog = yield this.modelFor('blog').blogTask;
let comments = yield blog.get('comments');
return comments;
}).cancelOn('deactivate')
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
export default () => {
let foo = [1,2,3]
let output = foo.map( f => `.rule-${f}: { border-width:${f}px;});
return output;
}
/** Result
* [".rule-1: { border-width: 1px };",
* ".rule-2: { border-width: 2px };"
* ".rule-3: { border-width: 1px };"]