Skip to content

Instantly share code, notes, and snippets.

@rreckonerr
Last active November 30, 2020 17:28
Show Gist options
  • Save rreckonerr/daa00757ffcaf3f8519bf3614cd97f28 to your computer and use it in GitHub Desktop.
Save rreckonerr/daa00757ffcaf3f8519bf3614cd97f28 to your computer and use it in GitHub Desktop.
New Twiddle
import Controller from '@ember/controller';
import { inject as service } from "@ember/service";
import { computed } from "@ember/object";
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle';
@service myService;
get trackedCount() {
return this.myService.count;
}
@computed("myService.count")
get computedCount() {
return this.myService.count;
}
}
import Service from '@ember/service';
import { tracked } from "@glimmer/tracking";
import { action, set } from "@ember/object";
export default class MyService extends Service {
@tracked count = 0;
@action
increaseCount() {
set(this, "count", this.count + 1);
}
};
<h2>[Tracked] Count: {{this.trackedCount}}</h2>
<h2>[Computed] Count: {{this.computedCount}}</h2>
<button type="button" {{on "click" (action this.myService.increaseCount)}}>Increase Count</button>
{
"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.20.0",
"ember-template-compiler": "3.20.0",
"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