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 Controller from '@ember/controller'; | |
export default class ApplicationController extends Controller { | |
appName = 'Ember Twiddle'; | |
actions = { | |
sendData() { | |
this.transitionToRoute('received', { | |
queryParams: { | |
data: 'some-data' |
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', | |
ben: 'Ben Chen', | |
name: Ember.computed.or('width', 'height', 'ben'), | |
}); |
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.Component.extend({ | |
_privateProp: 1, | |
prop: Ember.computed({ | |
get() { | |
return this._privateProp; | |
}, | |
// Every time "prop" is set |
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({ | |
didRender() { | |
alert('rendered'); | |
} | |
}); |
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({ | |
actions: { | |
clearPlaceholder() { | |
this.set('placeholder', ''); | |
} | |
} | |
}); |
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'; | |
class AbortError extends Error { | |
} | |
function makeAbortable(promise) { | |
const abortController = new AbortController(); | |
const _promise = promise | |
.then(result => { | |
if (abortController.signal.aborted) { | |
throw new AbortError; |
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({ | |
inAppAlert: Ember.computed.readOnly('inAppAlertQueue.firstObject'), | |
init() { | |
this._super(...arguments); | |
this.set('inAppAlertQueue', [ | |
'hello', |
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({ | |
inappAlert: Ember.computed.readOnly('liveAlertsQueue.firstObject'), | |
init() { | |
this._super(...arguments); | |
this.set('liveAlertsQueue', []); | |
}, | |
// This just fakes putting a queue on after the component is rendered |
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 EmberObject, { | |
observer | |
} from '@ember/object'; | |
export default Ember.Component.extend({ | |
alertWhenMultipleOfFive: observer('observable.progress', function() { | |
if (this.get('observable.progress') % 5 === 0) { | |
alert('Child says progress was a multiple of 5!'); | |
} |
NewerOlder