Refresh data on external event

Hi to all,
I have a page component with a list of conversations.
In app.js I have an event handler for received notification via onesignal.
How can I update page data from the event handler?
Is setState accessible from external? How? If so, is it a bad practice?
Thanks

ok, maybe solved:

  1. I’ve added app.emit inside the received notification handler
  2. I’ve added app.on inside the page component initPage. In the app.on i’ve queried db and called setState
    P.S. Little problem: app.on is called two times

Make sure you also call app.off in this component’s pageBeforeRemove to avoid attaching handler multiple times

1 Like

Thanks very much Vladimir!