adopted-ember-addons / ember-notify

Notification messages for your Ember.js app
MIT License
264 stars 100 forks source link

In Glimmer: EmberObject.create no longer supports defining computed properties #155

Closed gvocale closed 4 years ago

gvocale commented 4 years ago

I am trying to do the following:

// notifications/index.ts

import { action } from '@ember/object';
import Component from '@glimmer/component';

import Notify from 'ember-notify';

export default class Notifications extends Component {
  alternativeNotify = Notify.property();

  @action
  shootNotification() {
    this.alternativeNotify.success('Hello from the controller');
  }
}

and

// notifications/index.hbs

<button type="button" {{on "click" this.shootNotification}}>
  Shoot
</button>
<EmberNotify @source={{this.alternativeNotify}} />

But I get the following error in console:

Uncaught Error: Assertion Failed: EmberObject.create no longer supports defining computed properties. Define computed properties using extend() or reopen() before calling create().
gvocale commented 4 years ago

Rewriting it this way seem to have fixed the issue:

import Component from '@glimmer/component';
import { action } from '@ember/object';

export default class MyComponent extends Component {
  alternativeNotify;

  constructor(owner, args) {
    super(owner, args);
    this.alternativeNotify = Notify.create();
  }

  @action
  clicked() {
    this.alternativeNotify.success('Hello from the controller');
  }
}
btecu commented 4 years ago

Ciao @gvocale! Do you mind submitting a pull request to update the documentation?

gvocale commented 4 years ago

@btecu I don't seem to have write access and be able to open the PR. Can I still open a PR in some other way?

btecu commented 4 years ago

You have to fork the repository, then make the changes and push it. Once that's done you should be able to open a pull request.

btecu commented 4 years ago

Fixed in #157.