mardi 26 novembre 2019

Ember.js: EmberObject.create error on computed property inside a mixin

I am upgrading my ember app from 3.9 to 3.10.

I started getting an error.

Assertion Failed: EmberObject.create no longer supports defining computed properties. Define computed properties using extend() or reopen() before calling create().

I am not 100% sure, but after some tracking down, this piece of code seems to be causing this error (the computed property inside this mixin).

import Mixin from '@ember/object/mixin';
import { get, set, computed } from '@ember/object';
import { inject as service } from '@ember/service';
import DS from 'ember-data';

const { PromiseArray } = DS;

export default Mixin.create({
  ajax: service(),
  intl: service(),

  patientAnalysis: computed(function() {
    return this.getPatientAnalysis();
  }),

This mixin is being imported and used in another component, like so

import Analyses from 'ui/mixins/components/patient/analyses';
[...]
export default Component.extend(Analyses, {

I have read a few thread about this specific error, such as this one, but I can't figure out exactly how to make this work. I am not even sure why I am getting this error from upgrading to version 3.10 as this does not seems to have been deprecated or removed in that version.

I tried rewritting my mixin as the example from the ember doc, but without success.

If anyone could help me out figure out what exactly is going on and how to fix it, that would be appreciated.




Aucun commentaire:

Enregistrer un commentaire