Skip to content

Instantly share code, notes, and snippets.

@rlivsey
Created March 30, 2022 22:33
Show Gist options
  • Save rlivsey/9f10b4e5dcf99d6a12e1298cdb0d7528 to your computer and use it in GitHub Desktop.
Save rlivsey/9f10b4e5dcf99d6a12e1298cdb0d7528 to your computer and use it in GitHub Desktop.
New Twiddle
import Component from '@glimmer/component';
import { inject as service } from '@ember/service';
export default class extends Component {
@service myService;
get bar() {
console.log(this.myService);
console.log(this.args.otherThing);
console.log(this.args.itemComponent);
}
}
import Component from '@glimmer/component';
export default class extends Component {
}
import Controller from '@ember/controller';
import { inject as service } from '@ember/service';
import { action } from '@ember/object';
export default class ApplicationController extends Controller {
@service myService;
appName = 'Ember Twiddle';
@action thingClicked(args) {
console.log('clicked', args);
}
}
import Helper from '@ember/component/helper';
import { inject as service } from '@ember/service';
export default class MyHelper extends Helper {
@service myService;
compute(positional, object) {
this.myService.things.pushObject(object.item);
}
}
import Service from '@ember/service';
import { tracked } from '@glimmer/tracking';
export default class MyService extends Service {
@tracked things = [];
}
{{my-helper
item=(component "other-component" thing="wibble" onClick=(fn this.thingClicked 123))
}}
<p>Things</p>
{{#each this.myService.things as |thing|}}
{{component thing}}
{{/each}}
{{component @itemComponent}}
{{this.bar}}
Some other component {{@thing}}
<button (on "click" @onClick)>
Click me
</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.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