question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

waitForProperty never yielded when used when @tracked property changes

See original GitHub issue

I’m not entirely sure if this is an e-c bug or an issue with Octane Edition, but combining waitForProperty with a @tracked property doesn’t work.

export default class SomeService extends Service {
  @tracked someProperty = false;

  @task(function *() {
    yield waitForProperty(this, 'someProperty');

    // this code is unreached even if `someProperty`
    // becomes true.
  }) aTaskThatWaits  
}

This appears to be caused by the various waitFor{*}s being based on addObserver.

Although I’d assume backwards interop at the EmberObject level to not break SemVer in Ember.js itself.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
andrewfancommented, Feb 28, 2020

@trek @rwjblue @maxfierke I got the same error and found that it happens because https://github.com/machty/ember-concurrency/blob/d6b30e8b55c18b1e3da97d880c7ef612a5168aab/addon/-wait-for.js#L96 here we are trying to call missing addObserver / removeObserver methods If I add those 2 missing methods everything works fine with @tracked @trek

import { addObserver, removeObserver } from '@ember/object/observers';

export default class SomeService extends Service {
  @tracked someProperty = false;

  addObserver() {
    addObserver(this, ...arguments);
  }

  removeObserver() {
    removeObserver(this, ...arguments);
  }

  @task(function *() {
    yield waitForProperty(this, 'someProperty');

    // this code is unreached even if `someProperty`
    // becomes true.
  }) aTaskThatWaits  
}

So I believe everything can be fixed with exported add/removeObserver methods

0reactions
Herriaucommented, Aug 11, 2021

Similarly I have found waitForProperty() to be unreliable for observing state derived from @tracked properties. It seems however that this isn’t an issue with EC itself but rather with Ember’s addObserver(). We are refactoring away from using EC as much as possible as a result, which is quite a shame as we had some good patterns going.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tracked Properties - Octane Upgrade Guide - Ember Guides
Ember's classic change tracking system used two methods to ensure that all data was accessed properly and updated correctly: get and set ....
Read more >
Ember component is rendering the number of time the tracked ...
I passed the isPlaying property from the component-class and I'm logging it to the console. Instead of logging the the value of isPlaying...
Read more >
Silk Test 18.5 - Micro Focus
Unless you are using a trial version, Silk Test requires a license. Note: A Silk Test license is bound to a specific version...
Read more >
eggPlant Release Notes - TestPlant - Yumpu
Use the copy file… to … syntax with sut: before the filename to indicate a ... Changed the add properties command and adding...
Read more >
Ember.js Octane vs Classic Cheat Sheet
Angle brackets components can be used as either inline or block components. There's no change in behavior. {{yield}} looks and works the same....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found