Skip to content

Instantly share code, notes, and snippets.

Avatar

Ryan Scott Subtletree

  • Wellington, New Zealand
View GitHub Profile
View jwt.js
import Ember from 'ember';
import Jwt from 'ember-simple-auth-token/authenticators/jwt';
export default Jwt.extend({
scheduleAccessTokenRefresh(expiresAt, token) {
if (this.refreshAccessTokens) {
expiresAt = this.resolveTime(expiresAt);
const now = this.getCurrentTime();
const wait = (expiresAt - now - this.refreshLeeway) * 1000; // 1000*whole equation, not just leeway
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
scrollCount: 0,
throttleCount: 0,
init() {
this._super(...arguments);
View components.child-component.js
import Ember from 'ember';
export default Ember.Component.extend({
mouseEnter() {
this.get('onHover')('hovering');
}
});
View components.child-component.js
import Ember from 'ember';
export default Ember.Component.extend({
mouseEnter() {
this.get('onHover')('hovering');
}
});
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
arr: [{},{},{},{},{},{},{},{},{},{}],
arrayLength: Ember.computed.alias('arr.length'),
arrayObserver: Ember.observer('arr.length', function() {
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
actions: {
createComment() {
let post = this.get('model');
let comment = this.get('store').createRecord('comment', {post});
post.set('comment', comment);
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
item: 'item',
actions: {
submitSpellingComponentAction(params, userEnteredAttempt) {
alert(`params: ${params} \nuserEnteredAttempt: ${userEnteredAttempt}`);
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
View controllers.application.js
import Ember from 'ember';
function computedNumber(num) {
return Ember.computed('multiplier', function() {
return this.get('multiplier') * num;
});
}
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
View components.child-component.js
import Ember from 'ember';
export default Ember.Component.extend({
didInsertElement() {
console.log('child | didInsertElement 1');
this._super(...arguments);
console.log('child | didInsertElement 2');
Ember.run.schedule('afterRender', () => {
You can’t perform that action at this time.