import {Events} from 'ionic-angular';
import {Events} from '../your/path/to/service/events';
events.subscribe('user:created', (user, time) => {
console.log('Welcome', user, 'at', time);
});
this.events.subscribe('user:created', (data: any) => {
console.log('Welcome', data.user, 'at', data.time);
});
this.events.publish('user:created', someUserInstance, Date.now());
this.events.publish('foo:user:logged-out', {
user: someUserInstance,
time: new Date()
});
const subscription = this.events.subscribe('user:foo:created', (data: any) => {
// your logic
});
Once you are done, you can do this-
subscription.unsubscribe();
Apologies for the late reply. Where are you getting undefined for
this.channels[topic]
? I mean where have you added this log? Please give me the line number