diff --git a/core/container/container/lib/src/container.dart b/core/container/container/lib/src/container.dart index 5fb963a5..5fd7576d 100644 --- a/core/container/container/lib/src/container.dart +++ b/core/container/container/lib/src/container.dart @@ -236,4 +236,28 @@ class Container { _namedSingletons[name] = object; return object; } + + /// Register a scoped instance (new instance per scope). + void registerScoped(T Function(Container) factory) { + // Implement scoped behavior + // This is a simplified version; you might need to implement + // proper scoping mechanism based on your requirements + var scope = {}; + registerFactory((c) { + if (!scope.containsKey(T)) { + scope[T] = factory(c); + } + return scope[T] as T; + }); + } + + /// Register a transient instance (new instance every time). + void registerTransient(T Function(Container) factory) { + registerFactory((c) => factory(c)); + } + + /// Register a constant value. + void registerConstant(T value) { + registerFactory((c) => value); + } }