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

BUG: Reproduce modifier recalculation issue #647

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Mar 23, 2022

  1. BUG: Reproduce modifier recalculation issue

    These tests are a starting point to discuss a strange behavior I only
    see with Changesets and Modifiers.
    
    My best understanding is that the interaction between changesets and
    modifiers causes them to recalculate even when unrelated properties of
    the changeset are modified.
    
    This might seem expected at first till you realize that this behavior
    does not happen with helpers and also with non-changeset objects.
    
    This PR had to add `ember-modifier` and
    `ember-functions-as-modifiers-polyfill` addons to show the expected use
    case for these two modifier addons.
    
    The simplest code example I have is this:
    
    ```js
    import { modifier } from 'ember-modifier';
    
    export default modifier(function countModifierUpdates() {
      // NOTE there is no consuming any tracked properties here
      console.count('count-modifier-updates updated');
    });
    ```
    
    ```hbs
    {{#with (changeset
      (hash foo="foo will not change" bar="bar will change")
    ) as |changesetObj|}}
    
      {{! NOTE changesetObj.foo never changes }}
      <div {{count-modifier-updates changesetObj.foo}}></div>
    
      <button id="submit-btn" {{on "click"
        (fn (changeset-set changesetObj "bar") "bar has changed")
      }}>Click</button>
    
    {{/with}}
    ```
    sukima committed Mar 23, 2022
    Configuration menu
    Copy the full SHA
    d6e7f9a View commit details
    Browse the repository at this point in the history