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

Error on subscribe in ember 3.16.2 #13

Open
eliel-jr opened this issue Feb 21, 2020 · 2 comments
Open

Error on subscribe in ember 3.16.2 #13

eliel-jr opened this issue Feb 21, 2020 · 2 comments

Comments

@eliel-jr
Copy link

i try

@subscribe('events.backbutton', () => {
    this.broadcast('backbutton');
}) onBackButton;

i get error throw

Cannot read property 'get' of undefined TypeError: Cannot read property 'get' of undefined
at computedFn (file:///android_asset/www/assets/vendor.js:146194:30)
at file:///android_asset/www/assets/sgc-online.js:40966:412
at Array.reduce ()
at _applyDecoratedDescriptor (file:///android_asset/www/assets/sgc-online.js:40966:369)
at Module.callback (file:///android_asset/www/assets/sgc-online.js:41206:22)
at Module.exports (file:///android_asset/www/assets/vendor.js:118:32)
at requireModule (file:///android_asset/www/assets/vendor.js:39:18)
at Class._extractDefaultExport (file:///android_asset/www/assets/vendor.js:164606:20)
at Class.resolveOther (file:///android_asset/www/assets/vendor.js:164266:32)
at Class.resolve (file:///android_asset/www/assets/vendor.js:164329:25)

if i use, not registry event.

onBackButton = subscribe('events.backbutton', () => {
    this.broadcast('backbutton');
});
@eliel-jr
Copy link
Author

But in "ember-cordova-events/utils/subscribe" throw send

'this' is undefined in subscribe function here:

 if (Ember.isBlank(this.get(service)) || Ember.isPresent(_listener)) {
    return;
 } // ensure teardown

@eliel-jr
Copy link
Author

i'm using method "on" of the service "ember-cordova/events" in class constructor with an alternative of "utils/subscribe"

export default class PlatformService extends Service {

  @service('ember-cordova/platform') cordovaPlatform;
  @service('ember-cordova/events') events;

...

constructor() {
   super(...arguments);
   const events = this.events;
   events.on("backbutton", this, 'onBackButton');    
}

...

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

No branches or pull requests

1 participant