Last active
September 19, 2018 15:01
-
-
Save btecu/1ea116e14e0ea5240859fd29152b2f6f to your computer and use it in GitHub Desktop.
Component Lifecycle Mut
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('\ninit', this.get('vInit')); | |
this.set('vInit', 99); | |
}, | |
didReceiveAttrs() { | |
this._super(...arguments); | |
console.log('\ndidReceiveAttrs', this.get('vDidReceiveAttrs')); | |
this.set('vDidReceiveAttrs', 99); | |
}, | |
willRender() { | |
this._super(...arguments); | |
console.log('\nwillRender', this.get('vWillRender')); | |
this.set('vWillRender', 99); | |
}, | |
didInsertElement() { | |
this._super(...arguments); | |
//console.log('\ndidInsertElement', this.get('vDidInsertElement')); | |
//this.set('vDidInsertElement', 99); | |
} | |
}); |
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'; | |
const { | |
Controller, | |
observer | |
} = Ember; | |
export default Controller.extend({ | |
appName: 'Ember Twiddle', | |
vInit: 1, | |
vDidReceiveAttrs: 2, | |
vWillRender: 3, | |
vDidInsertElement: 4, | |
oInit: observer('vInit', function() { | |
console.log('init changed value', this.get('vInit')); | |
}), | |
oDidReceiveAttrs: observer('vDidReceiveAttrs', function() { | |
console.log('didReceiveAttrs changed value', this.get('vDidReceiveAttrs')); | |
}), | |
oWillRender: observer('vWillRender', function() { | |
console.log('willRender changed value', this.get('vWillRender')); | |
}), | |
oDidInsertElement: observer('vDidInsertElement', function() { | |
console.log('didInsertElement changed value', this.get('vDidInsertElement')); | |
}) | |
}); |
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 { run } from '@ember/runloop'; | |
export default function destroyApp(application) { | |
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'; | |
import { start } from 'ember-cli-qunit'; | |
setResolver(resolver); | |
start(); |
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.10.2", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "3.2.1", | |
"ember-template-compiler": "3.2.2" | |
}, | |
"addons": {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment