Skip to content
This repository has been archived by the owner on Oct 29, 2024. It is now read-only.

[Q] Custom dirty tracking with Glimmer #126

Closed
evil-shrike opened this issue Jun 8, 2018 · 3 comments
Closed

[Q] Custom dirty tracking with Glimmer #126

evil-shrike opened this issue Jun 8, 2018 · 3 comments

Comments

@evil-shrike
Copy link

evil-shrike commented Jun 8, 2018

Hi

I have objects for keeping model data. I call them domain objects. They are instances of classes corresponding to model entities. Like you know Department, Employee, User and so on. These objects have nothing to do with the UI layer. But they can be used as a model for UI components.
Let's imagine we have a Glimmer component (e.g. "Editor") that should provide UI for editing some domain object (e.g. User).
These objects already have a mechanism for dirty tracking. For every entity property in model there's a function like prop() that can be used as set/get accessor and on property value change there're events on object ("change" and "change:prop"). I guess it's similar to old Ember.

So now I'm thinking can I use these objects with Glimmer and how.

Can I integrate my dirty tracking with Glimmer? And how could it be approached?

@lifeart
Copy link
Contributor

lifeart commented Jun 20, 2018

glimmer playground example

glimmer playground example2

@evil-shrike
Copy link
Author

thank you! it's a clever approach, but not quite that I thought about. In this approach I'll have to use a method on a component to modify its model. I'd prefer to have dirty tracking w/o additional level of indirection: oninput={{action user.firstName}}
It's not about just syntax, imagine some business logic that modifies objects, it'd be cumbersome to manually call a special method on a component that owns object graph to notify engine.
Ideally I'd like to be able to notify Glimmer from objects' internals in some way that compatible with @track aspect...

@lifeart
Copy link
Contributor

lifeart commented Jun 20, 2018

take a look at second example, on render time you may pass component rerender-trigger-fn to your model, and this model can invoke callback to trigger rerender.
as benifit - you always know is your model usied inside any component or not

  • but, you neet to be careful about proper component destroying and unmounting

@locks locks closed this as completed Feb 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants