Skip to content
This repository has been archived by the owner on Jul 13, 2020. It is now read-only.

Linked Scopes - minispec #31

Open
apatrida opened this issue Feb 10, 2016 · 2 comments
Open

Linked Scopes - minispec #31

apatrida opened this issue Feb 10, 2016 · 2 comments

Comments

@apatrida
Copy link
Contributor

Not sure if this is useful, because you can manually get pretty close (see updated docs at https://github.com/kohesive/injekt/blob/master/README.md#scopes) using something like the shown MyActivityScope or MyActivityModule examples.

  1. Scope can be created and linked to another scope (or more than one scope). The scope you create is the “called scope” and the others are “linked scopes"
  2. The linking has the following properties: is the Linked scope allowed to provide existing cached instances (true by default), is Linked scope allowed to generate new instances (false by default), are new instances are cached in the called scope or the scope who’s factory actually makes the object which is either called scope or linked scope (called scope is the default).

so you would make myActivityScope linked to Injekt global

and anything already in global can be used, but it cannot create anything else, only myActivityScope can create new instances. And anything registered in myActivityScope will override the global Injekt by default

you can change the behaviour by the settings listed in # 2

So this would be called something like LocalOverridingScope with those defaults

others will want the settings to differ, such as having the global still make new instances of types it has registered but the other scope does not.

others will want the caching of the instances to be in the called scope, others in the scope that did the factory

others will want the factory called if the local scope does not have the item, but declare the factories only in the linked scope (including singleton factories)

@apatrida
Copy link
Contributor Author

@apatrida
Copy link
Contributor Author

#32 might be good enough solution not requiring #31

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant