So how does one hook up Events correctly?


#1

The documentation is sparse.

I know how events work, and have it working in my app. Just don’t know how to correctly hook it up.

I have several components (pages) who are dependant on Events to get datasource updates.
At first I simply added the events.subscribe( ... ) in the constructor of said components, but it seems the constructor gets run every time you enter that page - so I end up getting subscribed to the same event many many times.

How do I make these events run ONCE per component?


#2

You can unsubscribe to the event when the view is left.
event.unsubscribe(…)


#3

I need the data to be updated whether or not the view is active.

EDIT:
Maybe I’m not using events they are intended, I’ve moved the events out of the components, as that was causing problems, and into the services.

The views are not databound directly to the services instead of having local data.

Probably a better solution anyway.

EDIT2:

This doesn’t seem to work either.