
react4j.arez.ReactArezComponent Maven / Gradle / Ivy
package react4j.arez;
import arez.Arez;
import arez.ArezContext;
import arez.Disposable;
import arez.Observer;
import arez.annotations.Action;
import arez.annotations.ComponentId;
import arez.annotations.ContextRef;
import arez.annotations.ObserverRef;
import arez.annotations.OnDepsChanged;
import arez.annotations.Track;
import arez.spy.ObservableInfo;
import elemental2.core.JsObject;
import java.util.List;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import jsinterop.base.Js;
import jsinterop.base.JsPropertyMap;
import org.realityforge.braincheck.Guards;
import react4j.core.Component;
import react4j.core.Procedure;
import react4j.core.ReactNode;
import react4j.core.util.JsUtil;
/**
* A base class for all Arez enabled components. This class makes the component
* rendering reactive and it will schedule a re-render any time any of the observable
* entities accessed within the scope of the render method are changed.
*
* To achieve this goal, the props and state of the component are converted into
* observable properties. This of course means they must be accessed within the scope
* of an Arez transaction. (Typically this means it needs to be accessed within the
* scope of a {@link Action} annotated method or within the scope of the render method.
*/
public abstract class ReactArezComponent
extends Component
{
/**
* Key used to store the arez data in state.
*/
private static final String AREZ_STATE_KEY = "arez";
private static int c_nextComponentId = 1;
private final int _arezComponentId;
private boolean _renderDepsChanged;
protected ReactArezComponent()
{
_arezComponentId = c_nextComponentId++;
}
/**
* Method invoked when props changes.
*/
protected abstract void reportPropsChanged( @Nullable final JsPropertyMap
© 2015 - 2025 Weber Informatics LLC | Privacy Policy