toor library
Toor makes service locators compile-time safe and easy to manage.
Classes
- ResettableLocator
- The interface that all resettable locators implement.
- Toor
- A simple service locator manager that lets you register compile-time safe factories and lazy singletons.
-
ToorLocator<
T> - Used for interacting with factories or singletons registered with Toor.
-
ToorLocatorAsync<
T> - The class for using async factories registered with Toor.
-
ToorLocatorAsyncWithOneParameter<
T, P1> - Used for interacting with factories or singletons registered with Toor.
-
ToorLocatorAsyncWithTwoParameters<
T, P1, P2> - Used for interacting with factories or singletons registered with Toor.
- ToorLocatorBase
- The base for all types of locators.
-
ToorLocatorWithOneParameter<
T, P1> - Used for interacting with factories or singletons registered with Toor.
-
ToorLocatorWithTwoParameters<
T, P1, P2> - Used for interacting with factories or singletons registered with Toor.
-
ToorMutableLocator<
T> - ToorLocator with methods to change the current value.
Functions
-
registerFactory<
T> (FactoryFunc< T> factoryFunc) → ToorLocator<T> -
Registers a factory (i. e. a new instance of
T
will be created viafactoryFunc
on every call ofToorFactory.create()
). -
registerFactoryAsync<
T> (FactoryFuncAsync< T> factoryFunc) → ToorLocatorAsync<T> -
Registers an asynchronous factory via
factoryFunc
. -
registerFactoryAsyncWithParam<
T, P1> (FactoryFuncAsyncWithOneParameter< T, P1> factoryFunc) → ToorLocatorAsyncWithOneParameter<T, P1> -
Registers an asynchronous factory via
factoryFunc
. -
registerFactoryAsyncWithTwoParams<
T, P1, P2> (FactoryFuncAsyncWithTwoParameters< T, P1, P2> factoryFunc) → ToorLocatorAsyncWithTwoParameters<T, P1, P2> -
Registers an asynchronous factory via
factoryFunc
. -
registerFactoryWithParam<
T, P1> (FactoryFuncWithOneParameter< T, P1> factoryFunc) → ToorLocatorWithOneParameter<T, P1> -
Registers a factory (i. e. a new instance of
T
will be created viafactoryFunc
on every call ofToorFactory.create()
). {@macro ToorRegisterFactory} -
registerFactoryWithTwoParams<
T, P1, P2> (FactoryFuncWithTwoParameters< T, P1, P2> factoryFunc) → ToorLocatorWithTwoParameters<T, P1, P2> -
Registers a factory (i. e. a new instance of
T
will be created viafactoryFunc
on every call ofToorFactory.create()
). {@macro ToorRegisterFactory} -
registerLazySingleton<
T> (FactoryFunc< T> lazySingletonCreator, {DisposeFunc<T> ? onDispose}) → ToorLocator<T> - Registers a singleton which will be created once called.
-
registerMutableLazySingleton<
T> ({FactoryFunc< T> ? create, DisposeFunc<T> ? onDispose}) → ToorMutableLocator<T> -
Registers a singleton which has a mutable value.
In order to mutate the value of the singleton,
call
put
.
Typedefs
-
DisposeFunc<
T> = void Function(T locator) -
Signature for
onDispose
parameter of some locators' register function. -
FactoryFunc<
T> = T Function() - Signature for factory and lazy singleton creator functions.
-
FactoryFuncAsync<
T> = Future< T> Function() - Signature for asynchronous factories.
-
FactoryFuncAsyncWithOneParameter<
T, P1> = Future< T> Function(P1 param1) - Signature for one-parameter async factory creator functions.
-
FactoryFuncAsyncWithTwoParameters<
T, P1, P2> = Future< T> Function(P1 param1, P2 param2) - Signature for two-parameter async factory creator functions.
-
FactoryFuncWithOneParameter<
T, P1> = T Function(P1 param1) - Signature for one-parameter factory and lazy singleton creator functions.
-
FactoryFuncWithTwoParameters<
T, P1, P2> = T Function(P1 param1, P2 param2) - Signature for two-parameter factory and lazy singleton creator functions.