Last active
November 16, 2018 13:15
-
-
Save mistahenry/fc955f8d5d594cac0709c8d91f41a5ae to your computer and use it in GitHub Desktop.
New Twiddle
This file contains 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 { inject } from '@ember/service'; | |
import { computed } from '@ember/object'; | |
export default Ember.Component.extend({ | |
modeService: inject(), | |
renderList: computed('modeService.mode', function(){ | |
let mode = this.get('modeService.mode'); | |
return mode === 'list'; | |
}) | |
}); |
This file contains 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.set('languages', [ | |
'javascript', 'swift', 'groovy', 'haskell' | |
]); | |
} | |
}); |
This file contains 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 { inject } from '@ember/service'; | |
import { computed } from '@ember/object'; | |
export default Ember.Component.extend({ | |
modeService: inject(), | |
buttonText: computed('modeService.mode', function(){ | |
let mode = this.get('modeService.mode'); | |
return mode === 'list' ? "Change to table" : "Change to list"; | |
}), | |
actions: { | |
toggleMode(){ | |
let modeService = this.get('modeService'); | |
modeService.toggleMode(); | |
} | |
} | |
}); |
This file contains 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._super(...arguments); | |
//actually read from local storage here and set default on null | |
this.set('mode', 'list'); | |
}, | |
toggleMode(){ | |
let newValue = this.get('mode') === 'list' ? 'table' : 'list'; | |
//actually store to local storage here before caching on the service | |
this.set('mode', newValue); | |
} | |
}); |
This file contains 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.15.1", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js", | |
"ember": "3.4.3", | |
"ember-template-compiler": "3.4.3", | |
"ember-testing": "3.4.3" | |
}, | |
"addons": { | |
"ember-data": "3.4.2" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment