Comments (8)
We'll be exploring some solutions to this issue soon.
That said, I'm actually excited to see how far we can get with shallow tracking. In ember, there is a cost to supporting things like @each
. There's a large performance cost associated with managing all the observers it installs. There's also a burden on the developer to use Ember's array APIs when interacting with the array.
from glimmer-component.
This is also needed for tracking the change of args
. Though maybe there will be a workaround later when didUpdate
hook is introduced.
from glimmer-component.
@michalsnik The solution is to use the data down, actions up programming model. Instead of trying to mutate the state of the todo in the todo-item directly, you should pass a callback in that mutates the todos from the root.
I've been working on implementing the todomvc app in glimmer but I need to fix this bug first: #34
from glimmer-component.
Thanks for a quick answer. I'm aware of the extra cost of this, but I'm not seeing other possible solutions to this problem. Also I found that if I pass object to a component, for example:
<todo-item @todo={{todo}} />
Then if I change one property of the given todo in parent component - the child component does not re-render. Is there any workaround to make it work?
from glimmer-component.
@mmun I know DDAU and I never wanted to mutate todo in todo-item. The problem is even if I mutate single todo in todos' parent component - the child component (todo-item) won't re-render. Maybe if I'd pass name and state separately instead of the full object it would work, but that's something I'd like to avoid. I'd be happy to see how you proceed with todomvc :)
from glimmer-component.
@michalsnik: Here's my first pass: https://github.com/glimmerjs/todomvc-demo.
The main data flow is set up, but there are still a few issues I'm going to leave for contributors.
from glimmer-component.
Coming from React world, it is very intuitive for me to think that whenever an argument to a child changes the component will re-render. But I think GlimmerJS chooses to re-validate the component tree whenever a tracked property is changed.
The current todo-mvc implementation chooses to create a todo store with title and completed as tracked properties.
import { tracked } from "@glimmer/component";
let _idSequence = 0;
export default class Todo {
private _id: number = _idSequence++;
@tracked title: string;
@tracked completed: boolean;
constructor(title: string, completed: boolean = false) {
this.title = title;
this.completed = completed;
}
toggle() {
this.completed = !this.completed;
}
}
So, a change to them should trigger a re-render. A new thing I noted here, one can have tracked
annotation outside the component.
My understanding is still a bit blurry but I wanted to share it either way. I think the circumstances under which a glimmer app re-renders is a crucial piece to understand.
from glimmer-component.
This repo has been merged with glimmerjs/glimmer.js (into a monorepo setup). I am not sure if this issue is still applicable, but if you could confirm it is still an ongoing concern and open it over there that would be very helpful.
Sorry for the noise, but thank you for your help!
from glimmer-component.
Related Issues (20)
- Can't reference non-configurable properties in template HOT 1
- Type checking errors with this.args HOT 4
- No documented block params HOT 8
- Computed Property Syntax HOT 1
- Async functions cause reference error HOT 6
- Give more descriptive error message when using child component outside of parent's template HOT 2
- Errors in actions are silently swallowed HOT 1
- `@tracked` doesn't play nice HOT 3
- tracked property using "args" not updating HOT 5
- tracked property set in didInsertElement is not triggering a re-render HOT 4
- Symbol object is not available in IE HOT 3
- didUpdate hook called before component is rerendered HOT 1
- Error starting an app following the getting started HOT 4
- Cannot track a property on a referenced object HOT 2
- tracked property (dependent on "args") in child component is out of sync HOT 12
- Glimme throws an error if template starts with `if` HOT 2
- Not clear how to pass data to component in tests HOT 6
- Fragment support HOT 1
- How to render dynamic templates? HOT 3
- Not clear how to debug component tests HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from glimmer-component.