Refs API - DevNatan/inventory-framework GitHub Wiki
Refs API allows you to assign a reference to a component in a context, that is a useful since components are not directly accessible.
Refs API is experimental and is not subject to the general compatibility guarantees given for the standard library: the behavior of such API may be changed or the API may be removed completely in any further release.
Refs API is a very simple API that creates a link to a component. A common use case of Refs API is: I have a component X in my view, specified in onRender and I want to update it on some other handler like onClick, how do I do it? Let's see!
abstract class PlatformView {
/** Creates a new unassigned reference instance. */
@ApiStatus.Experimental
protected final <E> Ref<E> ref();
}The code above is the method signature of a Ref. Like in State Management, a Ref is create in view class top level. You create a Ref globally and access it through a Context, exactly like states.