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();
Hi @fromage9747 apologies, you had to work around the problem. Can you confirm two things-
@Injectable({ providedIn: 'root' })
at the top of the service.providers
)?Apart from this, I will be able to help you out if you can provide any working repo whenever next you use this. Because this thing is working fine on all my complex & simply projects.
Thanks for reaching out again!