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

Sort computed decorator in Octane gives "this.notifyPropertyChange is not a function" error #17839

Closed
CodingItWrong opened this issue Apr 2, 2019 · 4 comments
Labels

Comments

@CodingItWrong
Copy link

I'm attempting to sort a list of Ember Data records, and add a new record to the list. In stable this works fine, but in Octane I get the following error (error shown is from Firefox):

TypeError: this.notifyPropertyChange is not a function

Minimal reproduction: https://github.com/CodingItWrong/octane-sort-test
Comparable stable app showing the error does not occur: https://github.com/CodingItWrong/ember-sort-test

Here's the class where the sorting happens:

import Component from '@glimmer/component';
import { action } from '@ember/object';
import { sort } from '@ember/object/computed';
import { inject as service } from '@ember/service';

export default class WidgetListComponent extends Component {
  @service store;

  sortProperties = Object.freeze(['id:desc']);

  @sort('args.widgets', 'sortProperties')
  sortedWidgets;

  @action
  addWidget() {
    const widget = this.store.createRecord('widget', { name: 'New Widget' });
    widget.save();
  }
}
@rwjblue
Copy link
Member

rwjblue commented Apr 2, 2019

Can you share the full stack trace?

@CodingItWrong
Copy link
Author

CodingItWrong commented Apr 2, 2019

@rwjblue Sure thing:

TypeError: this.notifyPropertyChange is not a function - reduce_computed_macros.js:983
    Ember
        propertySort
        sendEvent
        notifyObservers
        notifyPropertyChange
        notify
        chainsDidChange
        notifyPropertyChange
        arrayDidChange
        eachProxyArrayDidChange
        arrayContentDidChange
        arrayContentDidChange
        _arrangedContentArrayDidChange
        sendEvent
        arrayContentDidChange
        replaceInNativeArray
        replace
        pushObjects
        _pushInternalModels
        updateLiveRecordArray
        updateLiveRecordArray
        _flushPendingInternalModelsForModelName
        _flush

    invoke backburner.js:341
    flush backburner.js:233
    flush backburner.js:437
    _end backburner.js:1013
    end backburner.js:699
    _run backburner.js:1068
    _join backburner.js:1042
    join backburner.js:759
    createRecord Ember
    addWidget widget-list.js:29
    addWidget self-hosted:1003

@rwjblue
Copy link
Member

rwjblue commented Apr 2, 2019

The issue is here:

The reduced macros can absolutely not assume that this.notifyPropertyChange is "a thing".

I've submitted #17841 to fix.

@rwjblue rwjblue added the Octane label Apr 2, 2019
@CodingItWrong
Copy link
Author

Thanks, running locally off of that PR's branch confirms that it fixes the issue for me

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

No branches or pull requests

2 participants