Class ReactiveContainer
java.lang.Object
page.codeberg.rrangelo.contextfx.components.Container
page.codeberg.rrangelo.contextfx.reactive.components.ReactiveContainer
Reactive extension of the
Container that supports ReactFX observable types as dependencies.
ReactiveContainer extends the standard container with two additional capabilities:
- Reactive registration:
reactiveRegister(Class, String)creates an instance of the class, then wraps it in the appropriate ReactFX primitive (Var,Val, orEventStream) based on the declared field/parameter type before storing it. - Reactive resolution:
reactiveResolver(Class, String)retrieves an instance and casts it to the requested reactive type.
Generic type arguments are resolved at registration time via ParameterizedType so that
the inner value type can be instantiated recursively.
- Author:
- Ramon Rangel Osorio <ramon.rangel@protonmail.com>
- See Also:
-
Field Summary
Fields inherited from class page.codeberg.rrangelo.contextfx.components.Container
CONTAINER, DEFAULT_IDENTIFIER, IS_DEFAULT_CONSTRUCTOR, IS_PARAMETERIZED_CONSTRUCTOR -
Method Summary
Modifier and TypeMethodDescriptionstatic ReactiveContainerConvenience alias forgetReactiveInstance().static ReactiveContainerReturns the singletonReactiveContainerinstance.final voidreactiveRegister(Class<?> clazz, String identifier) Creates a reactive instance ofclazz, wraps it in the appropriate ReactFX primitive, and registers it under the given identifier.final <T> TreactiveResolver(Class<T> clazz, String identifier) Resolves a registered reactive component and casts it to the requested type.Methods inherited from class page.codeberg.rrangelo.contextfx.components.Container
createInstance, createInstanceByDefaultConstructor, createInstanceByParameterizedConstructor, createParametersInstances, getComponent, getComponent, getComponents, register, register, replace, resolver, validateClasNameAndIdentifier
-
Method Details
-
getReactiveInstance
Returns the singletonReactiveContainerinstance.- Returns:
- the application-wide reactive container
-
getInstance
Convenience alias forgetReactiveInstance().- Returns:
- the application-wide reactive container
-
reactiveRegister
Creates a reactive instance ofclazz, wraps it in the appropriate ReactFX primitive, and registers it under the given identifier.- Parameters:
clazz- the reactive class to instantiate and registeridentifier- the registration identifier; blank maps toContainer.DEFAULT_IDENTIFIER
-
reactiveResolver
Resolves a registered reactive component and casts it to the requested type.- Type Parameters:
T- the expected reactive component type- Parameters:
clazz- the class to resolveidentifier- the registration identifier; blank resolvesContainer.DEFAULT_IDENTIFIER- Returns:
- the registered component instance cast to
T - Throws:
IllegalArgumentException- if the class or identifier is not registered
-