Open jenweber opened 3 years ago
@NullVoxPopuli let me know your thoughts! Also if you can add me to this repo as a member, that would be helpful. I can make a feature branch that drafts this content as plain markdown and tag you for review whenever I have something new.
@jenweber Good plan!
Example of passing an attr to the component with one-way change. like @tracked internalState = this.args.externalState
, which will update if @externalState
is being changed, but not vice versa. The only way I see doing it is {{did-update @externalState this.changeInternalState}}
.
I'm generally in favor,
Some additional thoughts:
@glimmer/component
are non-reactive (which is different from some resource implementations.. and even though resources are new, the expectation of reactivity in a constructor is not -- had that come up in discord this morning w/r/t @glimmer/component
's constructor)
like @tracked internalState = this.args.externalState, which will update if @externalState is being changed,
if you happen to need this now, you'd do it like:
yarn add tracked-toolbax
@localCopy('args.text') myText; // can be set, re-sets to args.text when args.text changes
see: https://github.com/pzuraq/tracked-toolbox
if you wanted to do this vanilla, you can use the same approach as you would with class instance values:
import { cached } from '@glimmer/tracking';
import { getOwner, setOwner } from '@ember/application';
// ...
@cached
get myValue() {
let instance = new MyClass(this.args.externalState);
setOwner(instance, getOwner(this));
return instance;
}
then myValue
only creates a new MyClass
when externalState
changes.
Note that set/get owner not needed, but most folks like using services and stuff from their custom classes, and set/get owner enables that.
additional topics -- everything from here?: https://discuss.emberjs.com/t/collection-of-strict-mode-template-demos-of-various-concepts/19637 (as well as the provided demos on limber.glimdown.com (focus management, forms, etc etc)
and maybe also a collection of anti-patterns so that it's clear where the ecosystem stands?
by use-case alternatives, because effects are rare to reach for (or should be (even in React))
As much as possible, I would like to reuse code examples from the Octane cheatsheet, and then add more for template syntax. The 🆕 indicates things that do not have an example in the old cheatsheet. Please comment on anything you think is missing, what should be removed, and which of the 🆕 things are highest priority.
Ember Data also needs a cheat sheet, but I think it should be separate.
Using components in templates
Fetching data
Passing and mutating data
Interaction
General Template syntax & helpers
Routes
Component class
Notes from Twitter
Possible way to describe the template syntax: