Last active
February 6, 2018 12:05
-
-
Save ykaragol/7e42549a23edc703e957adf758d7a014 to your computer and use it in GitHub Desktop.
ember run loop trial
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.Component.extend({ | |
init(){ | |
this._super(...arguments); | |
console.log('init'); | |
}, | |
didReceiveAttrs(){ | |
console.log('didReceiveAttrs'); | |
}, | |
willRender(){ | |
console.log('willRender'); | |
}, | |
didRender(){ | |
console.log('didRender'); | |
/* | |
console.log(Ember.run.currentRunLoop.queues['afterRender']._queue); | |
if(Ember.run.currentRunLoop.queues['afterRender']._queue.length>2){ | |
console.log(Ember.run.currentRunLoop.queues['afterRender']._queue[1]); | |
} | |
if(Ember.run.currentRunLoop.queues['afterRender']._queue.length>4){ | |
console.log(Ember.run.currentRunLoop.queues['afterRender']._queue[5]); | |
} | |
*/ | |
alert(this.get('x')); | |
} | |
}); |
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({ | |
x:0, | |
init(){ | |
Ember.run(function(){ | |
console.log('initial run loop'); | |
}); | |
Ember.run.scheduleOnce('sync', function(){ | |
console.log('initial run, sync'); | |
}); | |
Ember.run.scheduleOnce('afterRender', function(){ | |
console.log('initial run, afterRender'); | |
}); | |
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')); | |
}); | |
}); | |
} | |
}); |
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 function destroyApp(application) { | |
Ember.run(application, 'destroy'); | |
} |
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 Resolver from '../../resolver'; | |
import config from '../../config/environment'; | |
const resolver = Resolver.create(); | |
resolver.namespace = { | |
modulePrefix: config.modulePrefix, | |
podModulePrefix: config.podModulePrefix | |
}; | |
export default resolver; |
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 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; | |
} |
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 resolver from './helpers/resolver'; | |
import { | |
setResolver | |
} from 'ember-qunit'; | |
setResolver(resolver); |
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.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