ScopedValue: Capturing current bindings
    Attila Kelemen 
    attila.kelemen85 at gmail.com
       
    Tue May 23 16:36:47 UTC 2023
    
    
  
My point is that the factory providing the value is provided by the
client of the DI framework, thus it can have access to scoped values.
For instance, it might want to retrieve the value for another binding.
However, the framework must prevent the problem that the calling
context would change the scope.
Daniel Avery <danielaveryj at gmail.com> ezt írta (időpont: 2023. máj.
23., K, 18:10):
>
> Would it not be sufficient to use a local variable to capture the current binding?
>
> ```
> ScopedValue<String> testValue = ScopedValue.newInstance();
>
> ScopedValue.where(testValue, "OuterValue", () -> {
>   String value = testValue.get();
>   withBinding(String.class, () -> value, () -> {
>     ScopedValue.where(testValue, "InnerValue", () -> {
>       System.out.println(getByType(String.class));
>     });
>   });
> });
> ```
>
> - Daniel
    
    
More information about the loom-dev
mailing list