UseDependency: Default constructor to get the T dependency. It’s similar to using Reactter.find.
UseDependency.get: Get a T dependency inmediately. It’s similar to using Reactter.get.
UseDependency.register: Register a builder function to create a T dependency. It’s similar to using Reactter.register.
UseDependency.create: Registers, creates and gets a T dependency inmediately. It’s similar to using Reactter.create.
UseDependency.lazyBuilder: Registers a builder function, to create a instance of the T dependency as Builder mode. It’s similar to using Reactter.lazyBuilder.
UseDependency.lazyFactory: Registers a builder function, to create a instance of the T dependency as Factory mode. It’s similar to using Reactter.lazyFactory.
UseDependency.lazySingleton: Registers a builder function, to create a instance of the T dependency as Singleton mode. It’s similar to using Reactter.lazySingleton.
UseDependency.builder: Registers, creates and gets a T dependency inmediately as Builder mode. It’s similar to using Reactter.builder.
UseDependency.factory: Registers, creates and gets a T dependency inmediately as Factory mode. It’s similar to using Reactter.factory.
UseDependency.singleton: Registers, creates and gets a T dependency inmediately as Singleton mode. It’s similar to using Reactter.singleton.
Arguments
id: An optional String value to identify the dependency of T type.
builder: A function that returns an instance of the dependency of T type.
mode: An optional DependencyMode value to define the dependency mode. Default value is DependencyMode.builder.
Learn more about it in DependencyMode.
Properties and methods
instance: A getter property to get the dependency instance of T type.
Methods inherited from ReactterState(Learn more here):
update: A method to notify changes after run a set of instructions.
refresh: A method to force to notify changes.
*bind: A method to bind an instance to it.
*unbind: A method to unbind an instance to it.
*dispose: A method to remove all listeners and free resources.
Usage
Finding a dependency
You can use the default constructor to obtain the dependency of T type, e.g.:
Identifying a dependency
You can use the id argument to identify the dependency. For example, to obtain a dependency by uniqueId:
Using the dependency
You can use the instance property to access the dependency.
Getting a dependency
You can use the UseDependency.get hook to get the dependency instance, e.g.:
Registering a dependency
You can use the UseDependency.register hook to register a builder function to create the dependency instance, e.g.:
Creating a dependency
You can use the UseDependency.create hook to create a dependency instance inmediately, e.g.:
Defining the dependency mode
You can use the mode argument to define the dependency mode. For example, to create a singleton dependency: