emberjs / emberjs/ember-render-modifiers

@model hash and did-update don't play well together

Open
#21 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
86
Forks
34
PR merge metrics
No merged PRs in 30d

Description

I've created a [reproduction of this issue](https://github.com/jrjohnson/at-model-sequence-reproduction) which I'll attempt to describe here:

When returning a hash from the routes model hook and then passing that hash into a component as split properties `` and then using those split properties in getters of the component to invoke `did-update` an exception will be thrown when leaving the route. You can see this in the reproduction by navigating between the routes with the console open. This same thing doesn't happen if `this.model` is used in place of `@model`.

What I suspect is happening is that `@model` gets torn down early and re-assigned to the incoming route. This causes the first property `@model.first` to change which triggers `did-update` to call the second getter which is now unable to access `this.args.second` because it is also gone.

I've reproduced this as a synchronous action, but we're hitting this issue when `did-update` calls a task which loads async state. That's why the modifier needs to trigger the action and it can't just be a getter itself.

I'm not sure if this is an issue with `did-update` or a broader issue with modifiers and tracked properties using the `@model` pattern, but this seemed like the right place to start.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.