Skip to content

Instantly share code, notes, and snippets.

@alexspeller
Created April 6, 2018 20:21
Show Gist options
  • Save alexspeller/b821d3ff5d232e895299a46413f0b8a1 to your computer and use it in GitHub Desktop.
Save alexspeller/b821d3ff5d232e895299a46413f0b8a1 to your computer and use it in GitHub Desktop.
New Twiddle
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
value: false,
latch: Ember.computed('value', '_latch', function() {
if(this.get('_latch')) { return this.get('_latch') }
if(this.get('value')) { this.set('_latch', this.get('value')) }
return this.get('value');
})
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
<br>
<br>
value: {{value}}
latch: {{latch}}
_latch: {{_latch}}
<button {{action (mut value) true}}>Set Value True</button>
<button {{action (mut value) false}}>Set Value False</button>
{
"version": "0.13.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.16.2",
"ember-template-compiler": "2.16.2",
"ember-testing": "2.16.2"
},
"addons": {
"ember-data": "2.16.3"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment