Last active
June 13, 2017 15:19
-
-
Save scalvert/b937012e94c7d1827dc6d3480835257a to your computer and use it in GitHub Desktop.
New Twiddle
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: 'Ember Twiddle' | |
}); |
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({ | |
actions: { | |
onFocus() { | |
this.send('focussed'); | |
} | |
} | |
}); |
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('my-route'); | |
}); | |
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({ | |
rafService: Ember.inject.service(), | |
beforeModel(transition) { | |
console.log('beforeModel'); | |
}, | |
model(params, transition) { | |
console.log('model'); | |
}, | |
afterModel(model, transition) { | |
console.log('afterModel'); | |
}, | |
serialize(model, params) { | |
console.log('serialize'); | |
return {paramName: paramValue}; | |
}, | |
renderTemplate() { | |
console.log('renderTemplate'); | |
this.render(); | |
}, | |
actions: { | |
didTransition() { | |
console.log('didTransition'); | |
}, | |
focussed() { | |
console.log('focussed'); | |
const rafService = this.get('rafService'); | |
rafService.schedule(function() { | |
console.log('after focussed'); | |
}); | |
} | |
}, | |
redirect(model, transition) { | |
console.log('redirect'); | |
}, | |
activate() { | |
console.log('activate'); | |
const rafService = this.get('rafService'); | |
rafService.schedule(function() { | |
console.log('raf callback'); | |
}); | |
}, | |
deactivate() { | |
console.log('deactivate'); | |
} | |
}); |
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.Service.extend({ | |
init() { | |
this.callbacks = []; | |
this._setup(); | |
}, | |
schedule(callback) { | |
this.callbacks.push(callback); | |
}, | |
_setup() { | |
const router = Ember.getOwner(this).lookup('router:main'); | |
router.on('didTransition', () => { | |
requestAnimationFrame(() => { | |
console.log('first raf'); | |
requestAnimationFrame(() => { | |
console.log('second raf'); | |
for (let i = 0; i < this.callbacks.length; i++) { | |
this.callbacks[i](); | |
} | |
}); | |
}); | |
}); | |
} | |
}); |
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" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment