Pass events between pages?


#1

Hi, i know how to create and pass events between a child an parent components, but what about pages? they aren’t exactly parent and child, how do i pass events between sibling components like pages? do i need to bind to an event in the @app class?


#2

I might be misunderstanding what you are asking but don’t you just subscribe to an event in one page and fire the event in another?

// subscribe
 this.events.subscribe('user:login', () => {
      this.updateSideMenuItems(true);
    });

// fire
this.events.publish('user:login');

#3

Is events an ionic 2 injectable? what i end up doing is set up a Rxjs subject in a service and emit from one page and subscribe in the other, how would be to do it with that events?


#4

Yes, its injectable. Have a look at the Conference app - the app.js subscribes to the event fired in providers/user-data.js


#5

I suppose it uses Rxjs underneath, i’ll look just for informative purposes but i think i will stay with what i have done.