Skip to content

Instantly share code, notes, and snippets.

@feanor07
Forked from ykaragol/components.my-component.js
Created February 6, 2018 07:23
Show Gist options
  • Save feanor07/8d07323f73592ab2cfc8d2ee78718f81 to your computer and use it in GitHub Desktop.
Save feanor07/8d07323f73592ab2cfc8d2ee78718f81 to your computer and use it in GitHub Desktop.
ember run loop trial
import Ember from 'ember';
export default Ember.Component.extend({
didReceiveAttrs(){
console.log('didReceiveAttrs');
},
willRender(){
console.log('willRender');
},
didRender(){
console.log('didRender');
alert(this.get('x'));
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
x:0,
init(){
Ember.run.later(this, this.test, 500);
},
test(){
let that = this;
Ember.run.next(this, function(){
console.log('in next 1', that.incrementProperty('x'));
/* dom'u gerçekten güncelledikten sonra run.next çalışıyor. */
});
Ember.run(function(){
console.log('run 1:', that.incrementProperty('x'));
Ember.run.schedule('render', function(){
console.log('in render 1:', that.incrementProperty('x'));
});
Ember.run.schedule('afterRender', function(){
console.log('in afterRender 1', that.incrementProperty('x'));
});
Ember.run.schedule('afterRender', function(){
console.log('in afterRender 2', that.incrementProperty('x'));
});
Ember.run.schedule('routerTransitions', function(){
console.log('in routerTransitions 1', that.incrementProperty('x'));
});
Ember.run.schedule('sync', function(){
console.log('in sync 1:', that.incrementProperty('x'));
Ember.run(function(){
console.log('run 1.2:', that.incrementProperty('x'));
Ember.run.schedule('sync', function(){
console.log('in sync 1.2:', that.incrementProperty('x'));
});
Ember.run.schedule('actions', function(){
console.log('in actions 1.2:', that.incrementProperty('x'));
});
Ember.run.schedule('render', function(){
console.log('in render 1.2:', that.incrementProperty('x'));
});
Ember.run.schedule('afterRender', function(){
console.log('in afterRender 1.2:', that.incrementProperty('x'));
});
});
});
});
Ember.run(function(){
console.log('run 2', that.incrementProperty('x'));
Ember.run.schedule('sync', function(){
console.log('in sync 2.2:', that.incrementProperty('x'));
});
Ember.run.schedule('render', function(){
console.log('in render 2.2:', that.incrementProperty('x'));
});
});
}
});
import Ember from 'ember';
export default function destroyApp(application) {
Ember.run(application, 'destroy');
}
import Resolver from '../../resolver';
import config from '../../config/environment';
const resolver = Resolver.create();
resolver.namespace = {
modulePrefix: config.modulePrefix,
podModulePrefix: config.podModulePrefix
};
export default resolver;
import Ember from 'ember';
import Application from '../../app';
import config from '../../config/environment';
const { run } = Ember;
const assign = Ember.assign || Ember.merge;
export default function startApp(attrs) {
let application;
let attributes = assign({rootElement: "#test-root"}, config.APP);
attributes = assign(attributes, attrs); // use defaults, but you can override;
run(() => {
application = Application.create(attributes);
application.setupForTesting();
application.injectTestHelpers();
});
return application;
}
import resolver from './helpers/resolver';
import {
setResolver
} from 'ember-qunit';
setResolver(resolver);
{
"version": "0.13.0",
"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.16.2",
"ember-template-compiler": "2.16.2",
"ember-testing": "2.16.2"
},
"addons": {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment