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', | |
prop: 'a', | |
obj: { | |
a: 'value a', | |
b: 'value b', | |
c: 'value c' | |
} |
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
export default function makeComputed(objKey) { | |
let keys = Object.keys(get(this, objKey)) | |
.filter((key) => { | |
// choose the keys using some logic | |
}) | |
.map((key) => `${objKey}.${key}`); | |
return computed(...keys, { | |
get() { | |
// do stuff |
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', | |
init() { | |
this._super(...arguments); | |
this.items = [ | |
{ id: 1, name: 'first' }, | |
{ id: 2, name: 'second' }, |
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({ | |
a: [1,2,3], | |
b: [4,5,6], | |
c: false, | |
actions: { | |
toggleLabels() { | |
this.toggleProperty('c'); |
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({ | |
/** | |
Overall thoughts: Ember.Component needs a section in the module doc block outlining the order of events (just like the 1.13 blog post). | |
Individual events can then refer back to that lifecycle chart to avoid the "runs xth during re-renders but only on thursdays" sentences. | |
The module doc block should also get the section on what triggers a re-render (from the 1.13 blog post). | |
*/ | |
myProp: null, |
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:'Clock Service', | |
clock: Ember.inject.service() | |
}); |
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 RecordDeletedMixin from 'demo-app/mixins/record-deleted'; | |
export default Ember.Route.extend(RecordDeletedMixin, { | |
pushClient: Ember.inject.service('push-client'), | |
recordDeleted() { | |
alert("a post was deleted, but you are not on the post page so you don't care"); | |
}, | |
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
App.PushClient = Em.Object.extend | |
members: prop -> | |
Em.A() | |
connect: (key, userId) -> | |
return unless Pusher? | |
@pusher?.disconnect() | |
@pusher = new Pusher key, |
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
const MESSAGES = { | |
400: 'Bad syntax', | |
404: 'Could not find it', | |
500: 'You broke the server' | |
}; | |
function blah(statusCode) { | |
const msg = MESSAGES[statusCode] || 'idk lol'; | |
doSomethingWith(msg); | |
} |
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
#original attribution https://gist.github.com/alexspeller/6251054 & https://gist.github.com/stevekane/6356006 | |
App.ClickElsewhereMixin = Ember.Mixin.create | |
#use this method hook to define your desired behavior | |
onClickElsewhere: Ember.K | |
#bound version of our instance method | |
clickHandler: Em.computed -> | |
@onClickElsewhere.bind(@) |