-
Notifications
You must be signed in to change notification settings - Fork 19
Android specific examples #18
Comments
I'm working on Android example for scopes, linked, inherited, etc. Next big release will have features around that, and example app. |
Great! Thanks. |
Can you give example for the need for activity scope injection? I'm using injection for every functionality that doesn't belong to android UI (like db, network), and I inject those controllers to activity and fragments. |
Well. Default injector stores all objects graph in the global hash map. so when you inject something into activity, it will leak. for example i want to inject Toaster class, that depends on activity context. Now i doing something like this: special version of injectLazy that accepts scope objects as param
Create scope object inside activity; inject toaster:
define extension function:
Not sure if i doing it correct though :) |
Is there a non-ui usage for that? You can use extension methods for such functionality (anko has I think it has to do with #5, for clearing scope. But we still need an easier way to work with scopes. |
Yes i can use extension methods for toast and for everything else, so why to use injections at all :) |
So what we do need to have is an easier way of creating scope and clearing them. |
Just an idea:
custom injectLazy function
and use it
The main idea: weak references will be garbage collected in some point of time automagically |
I think it is still better to have a clear method, and make scope independent of a class reference, because until it is GCed it can cause memory leak. |
Yes. We can clear weakMap manually in onDestroy. |
When the next big update will be released? |
Please add more android specific stuff. For example how to implement Activity scoped injections. So when activity has been destroyed, it also should clean up objects graph
The text was updated successfully, but these errors were encountered: