-
Notifications
You must be signed in to change notification settings - Fork 208
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds Export option to Provide, which specifies that the provided constructor should be made available to all the Scopes in the same scope tree. For example: c := New() s1 := c.Scope("child 1") s2 := c.Scope("child 2") s2.Provide(func() *A { ... }) c.Invoke(func(a *A) { ... }) // errors s1.Invoke(func(a *A) { ...}) // errors will error out on Invoke because constructor providing *A is provided to the s2 only. With Export option, the child can provide this to all the Scopes in effect: c := New() s1 := c.Scope("child 1") s2 := c.Scope("child 2") s2.Provide(func() *A { ... }, Export(true)) c.Invoke(func(a *A) { ... }) // works! s1.Invoke(func(a *A) { ... }) // works! The implementation is quite simple - if this option is set, we provide it to the root Container. That provides the constructor visibility to all the scopes in effect.
- Loading branch information
Showing
4 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters