I have the following subscriber (in aSubscriber.js):
import {EventAggregator} from 'aurelia-event-aggregator';
export class Subscriber{
static inject = [EventAggregator];
constructor(eventAggregator){
this.eventAggregator = eventAggregator;
}
subscribe(){
this.eventAggregator.subscribe('myPublishChannelName', payload => {
//do something with the payload here
alert('got the message that has been published');
});
}
}
And in my class to register the subscriber I have:
import {inject} from 'aurelia-framework';
import {subscriber} from './aSubscriber';
@inject(subscriber)
export class Welcome{
constructor(subscriber){
// this.subscriber = subscriber;
// this.subscriber.subscribe();
}
}
In the constructor subscriber is undefined. Why is this happening?
Aucun commentaire:
Enregistrer un commentaire