-
Notifications
You must be signed in to change notification settings - Fork 7
Using IoC DI Containers
REstate at its heart is powered by an IoC/DI container abstraction. This abstraction allows REstate to work with any DI container library for which an adapter is built. In fact, REstate has an embedded container that will be used if no other is provided.
REstate's assumption about dependencies is that they are always singleton. However, you can still register and resolve transient dependencies by registering a factory that builds your actual dependency when needed.
When you provide REstate a Container, it will register all of its default bindings within that Container. This allows you to individually resolve components of REstate from the container such as IAgent
or IStateEngine<,>
. Additionally, while REstate has its own semantics and interfaces for adding dependencies and components, if you rather, you can instead directly write to your Container for more flexibility.
Finally, any component or dependency registered in the Container can be constructor injected into any REstate component such as an Action or Precondition.