I recently switched from SubCut to Scaldi and there's a feature I find undocumented/missing:
In SubCut, when you define a binding, you can choose between different binding modes - toSingle
, toProvider
, to moduleInstanceOf
, toModuleSingle
, which decide if the injected instances will be created once, or each time the bind is performed. I don't see the analogous behaviours explicitly defined in the Scaldi documentation, so I would like to make sure I understand how the different behaviours can be achieved in Scaldi:
By default the to
method is lazy and creates the injected instance the first time it's "requested". There's a toNonLazy
in the api which I guess creates the instance even before the first time it's "requested". And there's a toProvider
, which in the following example...
bind [Widget] toProvider new ParticularWidget()
...would create a new ParticularWidget
every time it is injected in an Injectable
.
Am I understanding this correctly?