sitefinitysteve / nativescript-google-analytics

Apache License 2.0
23 stars 14 forks source link

Allow plugin to initialize properly before application context is set. #37

Closed NathanaelA closed 6 years ago

NathanaelA commented 6 years ago

This uses a technique I use in several of my plugins to reliably get the context before NS has made it available for you to use. If the application.android.context is not setup, when init is called -- the plugin crashes.

We have ran into this attempting to use this as a angular service, that the android context value is still undefined, because somehow the services are being init'd before the application context is being set.

This technique also eliminates the need to import ANY of the application namespace which in the past (at least for a couple of my plugins) has broken things when my plugin required it before the main.js/app.js required it. So less dependencies is always a good thing. 😀

sitefinitysteve commented 6 years ago

Thx boss, I'll get'r published!

On Mon, Oct 23, 2017 at 7:06 PM, Nathanael Anderson < notifications@github.com> wrote:

This uses a technique I use in several of my plugins to reliably get the context before NS has made it available for you to use. If the application.android.context is not setup, when init is called -- the plugin crashes.

We have ran into this attempting to use this as a angular service, that the android context value is still undefined, because somehow the services are being init'd before the application context is being set.

This technique also eliminates the need to import ANY of the application namespace which in the past (at least for a couple of my plugins) has broken things when my plugin required it before the main.js/app.js required it. So less dependencies is always a good thing. 😀

You can view, comment on, or merge this pull request online at:

https://github.com/sitefinitysteve/nativescript-google-analytics/pull/37 Commit Summary

  • Allow plugin to initialize properly before application context is set.

File Changes

Patch Links:

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/sitefinitysteve/nativescript-google-analytics/pull/37, or mute the thread https://github.com/notifications/unsubscribe-auth/ABeI6EW5SbOR3rwJeFgwbavpk9LNIqG8ks5svRvjgaJpZM4QDneR .