Problems with events

Hi all,

Events solved many of my view changing problems across tabs. But from the time I updated to beta 10 , there seems to be a problem.

Code for events published is run

console.log(“Event sent, Fav:add”);
this.events.publish(‘fav:add’, data)

but sometimes events are received and sometimes not.

listenToFavEvents = () => {
this.events.subscribe(‘fav:add’, (data) => {
this.user.FavoriteProducts = [
…this.user.FavoriteProducts,
…data
];
console.log(data, ‘event received’, this.user.FavoriteProducts);

});

}

And it is very hard to debug async tasks. Is there any way to find out what the problem is , Does anyone else had that problem?

Any help is really appriciated.
thanks in advance!

i noticed that with beta 10 something internal changed within the page events in ionic2.

So for example --> i want to open an alert after the current component is the active page .
The Modal opens, but the page is not active, e.g. on iOS the background is totally black. If i add a timeout of round about 300ms the view is correctly shown and the modal overlays the view.

Maybe sometimes your events are firing before you add you added your listeners.

Are you using any view events of ionic?

1 Like

Omg, You are totally right… thanks a ton!!

The thing is, I am using tabs and in previous version I used preloadTabs="true"
After update to beta 10, I was getting following error

content.js:477 Uncaught TypeError: Cannot read property 'style' of undefined

The error shows 3 times if I have 4 tabs or 2 times if I have 3 tabs. And the app hangs.

So I removed preload attribute hence => the problem

Do you know anything about that error?

I have the same issue with beta 10. Did you found any solution?

sadly not yet. :frowning: … If I find something will post here :raised_hands: