Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracked property change still generating exception #465

Open
alverion opened this issue Jul 12, 2020 · 1 comment
Open

Tracked property change still generating exception #465

alverion opened this issue Jul 12, 2020 · 1 comment

Comments

@alverion
Copy link

On page 36 (book page not pdf page) i follow the instructions to change bands.js and include tracked property of name however upon returning to the browser i am still getting the following exception:

index.js:172 Uncaught Error: Assertion Failed: You attempted to update [object Object].name to "Test", but it is being tracked by a tracking context, such as a template, computed property, or observer. In order to make sure the context updates properly, you must invalidate the property when updating it. You can mark the property as @tracked, or use @ember/object#set to do this.
at assert (index.js:172)
at Object.set [as name] (index.js:869)
at :1:12

the command i am using is:

$E[1].name = "Test";

I reread many times and even restarted the server but have not been able to observe the change in name on the rendered page as stated.

Nef

@balinterdi
Copy link
Collaborator

So sorry for the long delay on this one.

In the latest stable version, 3.20, this should still work. The difference is that 3.20 has become more lax about throwing the above error. You should now:

  1. Not get the above error before marking the property as tracked but the template shouldn't update.
  2. After marking it as tracked, the template should update correctly.

The content of the bands.js route should be the following:

import Route from '@ember/routing/route';
import { tracked } from '@glimmer/tracking';

class Band {
  @tracked name;

  constructor(name) {
    this.name = name;
  }
}

export default class BandsRoute extends Route {
  model() {
    return [
      new Band('Led Zeppelin'),
      new Band('Pearl Jam'),
      new Band('Foo Fighters')
    ];
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants