Skip to content

Does it support deduped tracking? #232

@simonihmig

Description

@simonihmig

Hey, this looks pretty close to what I need, but I am not sure how it would deal with an immutable object, that is replaced for every change.

To give you an example: a (non-Ember) library is returning an immutable object, that drives the UI state. On every change of the application state, that library is asked to return a new object, which is then assigned to a tracked property, to update the UI. That even works without any "deep" tracking, just plain @tracked, as the whole object is replaced. But this causes all parts of the UI to rerender, even those where the actual value didn't change.

Some pseudo code to illustrate the example:

class GlobalStateService extends Service {
  @tracked globalState = { foo: 0, bar: 0};

  @action
  updateFoo() {
    // instead of mutating the foo property, we simulate the immutable behavior by assigned a new POJO
    this.globalState = { ...this.globalState, foo: this.globalState.foo + 1 };
  }
}

When I consume both globalState.foo and globalState.bar in a template, after calling updateFoo() both would re-render, as the whole globalState has been updated. But what I would like to see is that only the parts depending on globalState.foo re-render, but those depending on globalState.bar don't, as the actual value didn't change.

That's kinda the behavior of @dedupeTracked, but with deep tracking.

I assume that's not what ember-deep-tracked currently does, right? Do you think it would be feasible to support that?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions