OneSignal / react-onesignal

React OneSignal Module: Make it easy to integrate OneSignal with your React App!
Other
73 stars 26 forks source link

[question]: Why is Init async, and shouldnt the window["onesignal"] queue get initialized earlier? #78

Open timbrownsf opened 2 years ago

timbrownsf commented 2 years ago

How can we help?

Init doesnt look like it needs to be async. It would be nice if it wasnt - most 3rd party trackers arent. Also, the window["OneSignal"] property seems to only be instantiated inside of the handleOnLoad method (which is called after the script is loaded). Shouldnt the property and queue be initialized immediately during init/module import vs when the script asynchronously returns?

Thank you!

rgomezp commented 2 years ago

Howdy, Thanks for your patience.

I think you make an excellent point. Before making a decision, we would have to carefully consider the switch. That said, I can't think of a reason this cannot be done at the moment. However, note that we would not be able to remove this until a future major release.

If you could provide us with more info as to why this is important to you and how you are using the package, it may help guide us in our efforts.


Internal note: Related context: https://github.com/OneSignal/react-onesignal/pull/59

timbrownsf commented 2 years ago

This is important if someone tries to send data to OneSignal before the handleOnLoad method has been invoked

rgomezp commented 2 years ago

@timbrownsf , I see. Are you trying to do something like set user data tags?