Skip to content

Instantly share code, notes, and snippets.

@chriskrycho
Last active May 12, 2021 15:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chriskrycho/363ab9118dc2ea116fd51f45a783f9f4 to your computer and use it in GitHub Desktop.
Save chriskrycho/363ab9118dc2ea116fd51f45a783f9f4 to your computer and use it in GitHub Desktop.
state
import Controller from '@ember/controller';
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle';
}
import { helper } from '@ember/component/helper';
export default helper(([v]) => !v);
import { helper } from '@ember/component/helper';
import { tracked } from '@glimmer/tracking';
class State {
@tracked value;
constructor(value) {
this.value = value;
}
update = (newValue) => (this.value = newValue);
}
export default helper(([initial]) => new State(initial));
{{#let (state-from false) as |state|}}
<p>state: {{if state.value "yep" "nope"}}</p>
<button {{on "click" (fn state.update (not state.value))}}>flip it</button>
{{/let}}
{
"version": "0.17.1",
"EmberENV": {
"FEATURES": {},
"_TEMPLATE_ONLY_GLIMMER_COMPONENTS": false,
"_APPLICATION_TEMPLATE_WRAPPER": true,
"_JQUERY_INTEGRATION": true
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.js",
"ember": "3.18.1",
"ember-template-compiler": "3.18.1",
"ember-testing": "3.18.1"
},
"addons": {
"@glimmer/component": "1.0.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment