How to inject dependencies into a plugin? Or what is the best practice for a work around? #3923
Unanswered
sundeepgupta
asked this question in
Q&A
Replies: 2 comments 1 reply
-
Correct. There is no scheme to handle injection for you. The plugin is expected to manage its own dependencies. The bridge will call the load method on each plugin after it is instantiated and before it receives any calls from the application. So that is where it should configure anything that it will need later. |
Beta Was this translation helpful? Give feedback.
1 reply
-
A DI mechanism is definitely required for serious usage of capacitor, like the "ModuleFactory" approach in React Native. Nobody wants to handle god objects. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm looking at building an iOS plugin, although my question applies to Android as well. What I've noticed is that the plugin is initialized directly by the bridge. And obviously plugin function calls are also made by the bridge. So, it doesn't seem possible to use constructor or parameter injection. Is this correct? If so, I can see a couple of work arounds, but wanted to first make sure I'm not missing something.
Beta Was this translation helpful? Give feedback.
All reactions