Package arez

Class ArezContext

java.lang.Object
arez.ArezContext

public final class ArezContext extends Object
The ArezContext defines the top level container of interconnected observables and observers. The context also provides the mechanism for creating transactions to read and write state within the system.
  • Method Details

    • isComponentPresent

      @OmitSymbol(unless="arez.enable_native_components") public boolean isComponentPresent(@Nonnull String type, @Nonnull Object id)
      Return true if the component identified by type and id has been defined in context.
      Parameters:
      type - the component type.
      id - the component id.
      Returns:
      true if component is defined in context.
    • component

      @OmitSymbol(unless="arez.enable_native_components") @Nonnull public Component component(@Nonnull String type, @Nonnull Object id)
      Create a component with the specified parameters and return it. This method should only be invoked if Arez.areNativeComponentsEnabled() returns true. This method should not be invoked if isComponentPresent(String, Object) returns true for the parameters. The caller should invoke Component.complete() on the returned component as soon as the component definition has completed.
      Parameters:
      type - the component type.
      id - the component id.
      Returns:
      true if component is defined in context.
    • component

      @OmitSymbol(unless="arez.enable_native_components") @Nonnull public Component component(@Nonnull String type, @Nonnull Object id, @Nullable String name)
      Create a component with the specified parameters and return it. This method should only be invoked if Arez.areNativeComponentsEnabled() returns true. This method should not be invoked if isComponentPresent(String, Object) returns true for the parameters. The caller should invoke Component.complete() on the returned component as soon as the component definition has completed.
      Parameters:
      type - the component type.
      id - the component id.
      name - the name of the component. Should be null if Arez.areNamesEnabled() returns false.
      Returns:
      true if component is defined in context.
    • component

      @OmitSymbol(unless="arez.enable_native_components") @Nonnull public Component component(@Nonnull String type, @Nonnull Object id, @Nullable String name, @Nullable SafeProcedure preDispose)
      Create a component with the specified parameters and return it. This method should only be invoked if Arez.areNativeComponentsEnabled() returns true. This method should not be invoked if isComponentPresent(String, Object) returns true for the parameters. The caller should invoke Component.complete() on the returned component as soon as the component definition has completed.
      Parameters:
      type - the component type.
      id - the component id.
      name - the name of the component. Should be null if Arez.areNamesEnabled() returns false.
      preDispose - the hook action called just before the Component is disposed. The hook method is called from within the dispose transaction.
      Returns:
      true if component is defined in context.
    • component

      @OmitSymbol(unless="arez.enable_native_components") @Nonnull public Component component(@Nonnull String type, @Nonnull Object id, @Nullable String name, @Nullable SafeProcedure preDispose, @Nullable SafeProcedure postDispose)
      Create a component with the specified parameters and return it. This method should only be invoked if Arez.areNativeComponentsEnabled() returns true. This method should not be invoked if isComponentPresent(String, Object) returns true for the parameters. The caller should invoke Component.complete() on the returned component as soon as the component definition has completed.
      Parameters:
      type - the component type.
      id - the component id.
      name - the name of the component. Should be null if Arez.areNamesEnabled() returns false.
      preDispose - the hook action called just before the Component is disposed. The hook method is called from within the dispose transaction.
      postDispose - the hook action called just after the Component is disposed. The hook method is called from within the dispose transaction.
      Returns:
      true if component is defined in context.
    • computable

      @Nonnull public <T> ComputableValue<T> computable(@Nonnull SafeFunction<T> function)
      Create a ComputableValue with specified parameters.
      Type Parameters:
      T - the type of the computable value.
      Parameters:
      function - the function that computes the value.
      Returns:
      the ComputableValue instance.
    • computable

      @Nonnull public <T> ComputableValue<T> computable(@Nonnull SafeFunction<T> function, int flags)
      Create a ComputableValue with specified parameters.
      Type Parameters:
      T - the type of the computable value.
      Parameters:
      function - the function that computes the value.
      flags - the flags used to create the ComputableValue. The acceptable flags are defined in ComputableValue.Flags.
      Returns:
      the ComputableValue instance.
    • computable

      @Nonnull public <T> ComputableValue<T> computable(@Nullable String name, @Nonnull SafeFunction<T> function)
      Create a ComputableValue with specified parameters.
      Type Parameters:
      T - the type of the computable value.
      Parameters:
      name - the name of the ComputableValue.
      function - the function that computes the value.
      Returns:
      the ComputableValue instance.
    • computable

      @Nonnull public <T> ComputableValue<T> computable(@Nullable String name, @Nonnull SafeFunction<T> function, int flags)
      Create a ComputableValue with specified parameters.
      Type Parameters:
      T - the type of the computable value.
      Parameters:
      name - the name of the ComputableValue.
      function - the function that computes the value.
      flags - the flags used to create the ComputableValue. The acceptable flags are defined in ComputableValue.Flags.
      Returns:
      the ComputableValue instance.
    • computable

      @Nonnull public <T> ComputableValue<T> computable(@Nullable Component component, @Nullable String name, @Nonnull SafeFunction<T> function)
      Create a ComputableValue with specified parameters.
      Type Parameters:
      T - the type of the computable value.
      Parameters:
      component - the component that contains the ComputableValue if any. Must be null unless Arez.areNativeComponentsEnabled() returns true.
      name - the name of the ComputableValue.
      function - the function that computes the value.
      Returns:
      the ComputableValue instance.
    • computable

      @Nonnull public <T> ComputableValue<T> computable(@Nullable Component component, @Nullable String name, @Nonnull SafeFunction<T> function, int flags)
      Create a ComputableValue with specified parameters.
      Type Parameters:
      T - the type of the computable value.
      Parameters:
      component - the component that contains the ComputableValue if any. Must be null unless Arez.areNativeComponentsEnabled() returns true.
      name - the name of the ComputableValue.
      function - the function that computes the value.
      flags - the flags used to create the ComputableValue. The acceptable flags are defined in ComputableValue.Flags.
      Returns:
      the ComputableValue instance.
    • computable

      @Nonnull public <T> ComputableValue<T> computable(@Nullable Component component, @Nullable String name, @Nonnull SafeFunction<T> function, @Nullable Procedure onActivate, @Nullable Procedure onDeactivate)
      Create a ComputableValue with specified parameters.
      Type Parameters:
      T - the type of the computable value.
      Parameters:
      component - the component that contains the ComputableValue if any. Must be null unless Arez.areNativeComponentsEnabled() returns true.
      name - the name of the ComputableValue.
      function - the function that computes the value.
      onActivate - the procedure to invoke when the ComputableValue changes from the INACTIVE state to any other state. This will be invoked when the transition occurs and will occur in the context of the transaction that made the change.
      onDeactivate - the procedure to invoke when the ComputableValue changes to the INACTIVE state to any other state. This will be invoked when the transition occurs and will occur in the context of the transaction that made the change.
      Returns:
      the ComputableValue instance.
    • computable

      @Nonnull public <T> ComputableValue<T> computable(@Nullable String name, @Nonnull SafeFunction<T> function, @Nullable Procedure onActivate, @Nullable Procedure onDeactivate)
      Create a ComputableValue with specified parameters.
      Type Parameters:
      T - the type of the computable value.
      Parameters:
      name - the name of the ComputableValue.
      function - the function that computes the value.
      onActivate - the procedure to invoke when the ComputableValue changes from the INACTIVE state to any other state. This will be invoked when the transition occurs and will occur in the context of the transaction that made the change.
      onDeactivate - the procedure to invoke when the ComputableValue changes to the INACTIVE state to any other state. This will be invoked when the transition occurs and will occur in the context of the transaction that made the change.
      Returns:
      the ComputableValue instance.
    • computable

      @Nonnull public <T> ComputableValue<T> computable(@Nullable String name, @Nonnull SafeFunction<T> function, @Nullable Procedure onActivate, @Nullable Procedure onDeactivate, int flags)
      Create a ComputableValue with specified parameters.
      Type Parameters:
      T - the type of the computable value.
      Parameters:
      name - the name of the ComputableValue.
      function - the function that computes the value.
      onActivate - the procedure to invoke when the ComputableValue changes from the INACTIVE state to any other state. This will be invoked when the transition occurs and will occur in the context of the transaction that made the change.
      onDeactivate - the procedure to invoke when the ComputableValue changes to the INACTIVE state to any other state. This will be invoked when the transition occurs and will occur in the context of the transaction that made the change.
      flags - the flags used to create the ComputableValue. The acceptable flags are defined in ComputableValue.Flags.
      Returns:
      the ComputableValue instance.
    • computable

      @Nonnull public <T> ComputableValue<T> computable(@Nullable Component component, @Nullable String name, @Nonnull SafeFunction<T> function, @Nullable Procedure onActivate, @Nullable Procedure onDeactivate, int flags)
      Create a ComputableValue with specified parameters.
      Type Parameters:
      T - the type of the computable value.
      Parameters:
      component - the component that contains the ComputableValue if any. Must be null unless Arez.areNativeComponentsEnabled() returns true.
      name - the name of the ComputableValue.
      function - the function that computes the value.
      onActivate - the procedure to invoke when the ComputableValue changes from the INACTIVE state to any other state. This will be invoked when the transition occurs and will occur in the context of the transaction that made the change.
      onDeactivate - the procedure to invoke when the ComputableValue changes to the INACTIVE state to any other state. This will be invoked when the transition occurs and will occur in the context of the transaction that made the change.
      flags - the flags used to create the ComputableValue. The acceptable flags are defined in ComputableValue.Flags.
      Returns:
      the ComputableValue instance.
    • observer

      @Nonnull public Observer observer(@Nonnull Procedure observe)
      Create an "autorun" observer that reschedules observed procedure when dependency updates occur.
      Parameters:
      observe - the executable observed by the observer.
      Returns:
      the new Observer.
    • observer

      @Nonnull public Observer observer(@Nonnull Procedure observe, int flags)
      Create an "autorun" observer that reschedules observed procedure when dependency updates occur.
      Parameters:
      observe - the executable observed by the observer.
      flags - the flags used to create the observer. The acceptable flags are defined in Observer.Flags.
      Returns:
      the new Observer.
    • observer

      @Nonnull public Observer observer(@Nullable String name, @Nonnull Procedure observe)
      Create an "autorun" observer that reschedules observed procedure when dependency updates occur.
      Parameters:
      name - the name of the observer.
      observe - the executable observed by the observer.
      Returns:
      the new Observer.
    • observer

      @Nonnull public Observer observer(@Nullable String name, @Nonnull Procedure observe, int flags)
      Create an "autorun" observer that reschedules observed procedure when dependency updates occur.
      Parameters:
      name - the name of the observer.
      observe - the executable observed by the observer.
      flags - the flags used to create the observer. The acceptable flags are defined in Observer.Flags.
      Returns:
      the new Observer.
    • observer

      @Nonnull public Observer observer(@Nullable Component component, @Nullable String name, @Nonnull Procedure observe)
      Create an "autorun" observer that reschedules observed procedure when dependency updates occur.
      Parameters:
      component - the component containing the observer if any. Should be null if Arez.areNativeComponentsEnabled() returns false.
      name - the name of the observer.
      observe - the executable observed by the observer.
      Returns:
      the new Observer.
    • observer

      @Nonnull public Observer observer(@Nullable Component component, @Nullable String name, @Nonnull Procedure observe, int flags)
      Create an "autorun" observer that reschedules observed procedure when dependency updates occur.
      Parameters:
      component - the component containing the observer if any. Should be null if Arez.areNativeComponentsEnabled() returns false.
      name - the name of the observer.
      observe - the executable observed by the observer.
      flags - the flags used to create the observer. The acceptable flags are defined in Observer.Flags.
      Returns:
      the new Observer.
    • observer

      @Nonnull public Observer observer(@Nullable Component component, @Nullable String name, @Nullable Procedure observe, @Nullable Procedure onDepsChange)
      Create an observer. The user must pass either the observe or onDepsChange parameter.
      Parameters:
      component - the component containing the observer if any. Should be null if Arez.areNativeComponentsEnabled() returns false.
      name - the name of the observer.
      observe - the executable observed by the observer. May be null if observer is externally scheduled.
      onDepsChange - the hook invoked when dependencies changed. If this is non-null then it is expected that hook will manually schedule the observer by calling Observer.schedule() at some point.
      Returns:
      the new Observer.
    • observer

      @Nonnull public Observer observer(@Nullable Procedure observe, @Nullable Procedure onDepsChange)
      Create an observer. The user must pass either the observe or onDepsChange or both parameters.
      Parameters:
      observe - the executable observed by the observer. May be null if observer is externally scheduled.
      onDepsChange - the hook invoked when dependencies changed. If this is non-null then it is expected that hook will manually schedule the observer by calling Observer.schedule() at some point.
      Returns:
      the new Observer.
    • observer

      @Nonnull public Observer observer(@Nullable Procedure observe, @Nullable Procedure onDepsChange, int flags)
      Create an observer. The user must pass either the observe or onDepsChange or both parameters.
      Parameters:
      observe - the executable observed by the observer. May be null if observer is externally scheduled.
      onDepsChange - the hook invoked when dependencies changed. If this is non-null then it is expected that hook will manually schedule the observer by calling Observer.schedule() at some point.
      flags - the flags used to create the observer. The acceptable flags are defined in Observer.Flags.
      Returns:
      the new Observer.
    • observer

      @Nonnull public Observer observer(@Nullable String name, @Nullable Procedure observe, @Nullable Procedure onDepsChange)
      Create an observer. The user must pass either the observe or onDepsChange or both parameters.
      Parameters:
      name - the name of the observer.
      observe - the executable observed by the observer. May be null if observer is externally scheduled.
      onDepsChange - the hook invoked when dependencies changed. If this is non-null then it is expected that hook will manually schedule the observer by calling Observer.schedule() at some point.
      Returns:
      the new Observer.
    • observer

      @Nonnull public Observer observer(@Nullable String name, @Nullable Procedure observe, @Nullable Procedure onDepsChange, int flags)
      Create an observer. The user must pass either the observe or onDepsChange or both parameters.
      Parameters:
      name - the name of the observer.
      observe - the executable observed by the observer. May be null if observer is externally scheduled.
      onDepsChange - the hook invoked when dependencies changed. If this is non-null then it is expected that hook will manually schedule the observer by calling Observer.schedule() at some point.
      flags - the flags used to create the observer. The acceptable flags are defined in Observer.Flags.
      Returns:
      the new Observer.
    • observer

      @Nonnull public Observer observer(@Nullable Component component, @Nullable String name, @Nullable Procedure observe, @Nullable Procedure onDepsChange, int flags)
      Create an observer. The user must pass either the observe or onDepsChange or both parameters.
      Parameters:
      component - the component containing the observer if any. Should be null if Arez.areNativeComponentsEnabled() returns false.
      name - the name of the observer.
      observe - the executable observed by the observer. May be null if observer is externally scheduled.
      onDepsChange - the hook invoked when dependencies changed. If this is non-null then it is expected that hook will manually schedule the observer by calling Observer.schedule() at some point.
      flags - the flags used to create the observer. The acceptable flags are defined in Observer.Flags.
      Returns:
      the new Observer.
    • tracker

      @Nonnull public Observer tracker(@Nonnull Procedure onDepsChange)
      Create a tracking observer. The tracking observer triggers the onDepsChange hook function when dependencies in the observe function are updated. Application code is responsible for executing the observe function by invoking a observe method such as observe(Observer, Function).
      Parameters:
      onDepsChange - the hook invoked when dependencies changed.
      Returns:
      the new Observer.
    • tracker

      @Nonnull public Observer tracker(@Nonnull Procedure onDepsChange, int flags)
      Create a tracking observer. The tracking observer triggers the onDepsChange hook function when dependencies in the observe function are updated. Application code is responsible for executing the observe function by invoking a observe method such as observe(Observer, Function).
      Parameters:
      onDepsChange - the hook invoked when dependencies changed.
      flags - the flags used to create the observer. The acceptable flags are defined in Observer.Flags.
      Returns:
      the new Observer.
    • tracker

      @Nonnull public Observer tracker(@Nullable String name, @Nonnull Procedure onDepsChange)
      Create a tracking observer. The tracking observer triggers the onDepsChange hook function when dependencies in the observe function are updated. Application code is responsible for executing the observe function by invoking a observe method such as observe(Observer, Function).
      Parameters:
      name - the name of the observer.
      onDepsChange - the hook invoked when dependencies changed.
      Returns:
      the new Observer.
    • tracker

      @Nonnull public Observer tracker(@Nullable String name, @Nonnull Procedure onDepsChange, int flags)
      Create a tracking observer. The tracking observer triggers the onDepsChange hook function when dependencies in the observe function are updated. Application code is responsible for executing the observe function by invoking a observe method such as observe(Observer, Function).
      Parameters:
      name - the name of the observer.
      onDepsChange - the hook invoked when dependencies changed.
      flags - the flags used to create the observer. The acceptable flags are defined in Observer.Flags.
      Returns:
      the new Observer.
    • tracker

      @Nonnull public Observer tracker(@Nullable Component component, @Nullable String name, @Nonnull Procedure onDepsChange)
      Create a tracking observer. The tracking observer triggers the onDepsChange hook function when dependencies in the observe function are updated. Application code is responsible for executing the observe function by invoking a observe method such as observe(Observer, Function).
      Parameters:
      component - the component containing the observer if any. Should be null if Arez.areNativeComponentsEnabled() returns false.
      name - the name of the observer.
      onDepsChange - the hook invoked when dependencies changed.
      Returns:
      the new Observer.
    • tracker

      @Nonnull public Observer tracker(@Nullable Component component, @Nullable String name, @Nonnull Procedure onDepsChange, int flags)
      Create a tracking observer. The tracking observer triggers the onDepsChange hook function when dependencies in the observe function are updated. Application code is responsible for executing the observe function by invoking a observe method such as observe(Observer, Procedure).
      Parameters:
      component - the component containing the observer if any. Should be null if Arez.areNativeComponentsEnabled() returns false.
      name - the name of the observer.
      onDepsChange - the hook invoked when dependencies changed.
      flags - the flags used to create the observer. The acceptable flags are defined in Observer.Flags.
      Returns:
      the new Observer.
    • observable

      @Nonnull public <T> ObservableValue<T> observable()
      Create an ObservableValue synthesizing name if required.
      Type Parameters:
      T - the type of observable.
      Returns:
      the new ObservableValue.
    • observable

      @Nonnull public <T> ObservableValue<T> observable(@Nullable String name)
      Create an ObservableValue with the specified name.
      Type Parameters:
      T - the type of observable.
      Parameters:
      name - the name of the ObservableValue. Should be non null if Arez.areNamesEnabled() returns true, null otherwise.
      Returns:
      the new ObservableValue.
    • observable

      @Nonnull public <T> ObservableValue<T> observable(@Nullable String name, @Nullable PropertyAccessor<T> accessor, @Nullable PropertyMutator<T> mutator)
      Create an ObservableValue.
      Type Parameters:
      T - the type of observable.
      Parameters:
      name - the name of the observable. Should be non null if Arez.areNamesEnabled() returns true, null otherwise.
      accessor - the accessor for observable. Should be null if Arez.arePropertyIntrospectorsEnabled() returns false, may be non-null otherwise.
      mutator - the mutator for observable. Should be null if Arez.arePropertyIntrospectorsEnabled() returns false, may be non-null otherwise.
      Returns:
      the new ObservableValue.
    • observable

      @Nonnull public <T> ObservableValue<T> observable(@Nullable Component component, @Nullable String name)
      Create an ObservableValue.
      Type Parameters:
      T - The type of the value that is observable.
      Parameters:
      component - the component containing observable if any. Should be null if Arez.areNativeComponentsEnabled() returns false.
      name - the name of the observable. Should be non null if Arez.areNamesEnabled() returns true, null otherwise.
      Returns:
      the new ObservableValue.
    • observable

      @Nonnull public <T> ObservableValue<T> observable(@Nullable Component component, @Nullable String name, @Nullable PropertyAccessor<T> accessor)
      Create an ObservableValue.
      Type Parameters:
      T - The type of the value that is observable.
      Parameters:
      component - the component containing observable if any. Should be null if Arez.areNativeComponentsEnabled() returns false.
      name - the name of the observable. Should be non null if Arez.areNamesEnabled() returns true, null otherwise.
      accessor - the accessor for observable. Should be null if Arez.arePropertyIntrospectorsEnabled() returns false, may be non-null otherwise.
      Returns:
      the new ObservableValue.
    • observable

      @Nonnull public <T> ObservableValue<T> observable(@Nullable Component component, @Nullable String name, @Nullable PropertyAccessor<T> accessor, @Nullable PropertyMutator<T> mutator)
      Create an ObservableValue.
      Type Parameters:
      T - The type of the value that is observable.
      Parameters:
      component - the component containing observable if any. Should be null if Arez.areNativeComponentsEnabled() returns false.
      name - the name of the observable. Should be non null if Arez.areNamesEnabled() returns true, null otherwise.
      accessor - the accessor for observable. Should be null if Arez.arePropertyIntrospectorsEnabled() returns false, may be non-null otherwise.
      mutator - the mutator for observable. Should be null if Arez.arePropertyIntrospectorsEnabled() returns false, may be non-null otherwise.
      Returns:
      the new ObservableValue.
    • task

      @Nonnull public Task task(@Nonnull SafeProcedure work)
      Create and queue a task to be executed by the runtime. If the scheduler is not running then the scheduler will be triggered.
      Parameters:
      work - the representation of the task to execute.
      Returns:
      the new task.
    • task

      @Nonnull public Task task(@Nullable String name, @Nonnull SafeProcedure work)
      Create and queue a task to be executed by the runtime. If the scheduler is not running then the scheduler will be triggered.
      Parameters:
      name - the name of the task. Must be null if Arez.areNamesEnabled() returns false.
      work - the representation of the task to execute.
      Returns:
      the new task.
    • task

      @Nonnull public Task task(@Nonnull SafeProcedure work, int flags)
      Create and queue a task to be executed by the runtime. If the scheduler is not running and the Task.Flags.RUN_LATER flag has not been supplied then the scheduler will be triggered.
      Parameters:
      work - the representation of the task to execute.
      flags - the flags to configure task. Valid flags include PRIORITY_* flags, DISPOSE_ON_COMPLETE and RUN_* flags.
      Returns:
      the new task.
    • task

      @Nonnull public Task task(@Nullable String name, @Nonnull SafeProcedure work, int flags)
      Create and queue a task to be executed by the runtime. If the scheduler is not running and the Task.Flags.RUN_LATER flag has not been supplied then the scheduler will be triggered.
      Parameters:
      name - the name of the task. Must be null if Arez.areNamesEnabled() returns false.
      work - the representation of the task to execute.
      flags - the flags to configure task. Valid flags include PRIORITY_* flags, DISPOSE_ON_COMPLETE and RUN_* flags.
      Returns:
      the new task.
    • isSchedulerActive

      public boolean isSchedulerActive()
      Return true if the scheduler is currently executing tasks.
      Returns:
      true if the scheduler is currently executing tasks.
    • isTransactionActive

      public boolean isTransactionActive()
      Return true if there is a transaction in progress.
      Returns:
      true if there is a transaction in progress.
    • isTrackingTransactionActive

      public boolean isTrackingTransactionActive()
      Return true if there is a tracking transaction in progress. A tracking transaction is one created by an Observer via the observer(Procedure) or tracker(Procedure) methods.
      Returns:
      true if there is a tracking transaction in progress.
    • isReadWriteTransactionActive

      public boolean isReadWriteTransactionActive()
      Return true if there is a read-write transaction in progress.
      Returns:
      true if there is a read-write transaction in progress.
    • isReadOnlyTransactionActive

      public boolean isReadOnlyTransactionActive()
      Return true if there is a read-only transaction in progress.
      Returns:
      true if there is a read-only transaction in progress.
    • isSchedulerPaused

      public boolean isSchedulerPaused()
      Return true if the scheduler is paused. True means that pauseScheduler() has been called one or more times and the lock not disposed.
      Returns:
      true if the scheduler is paused, false otherwise.
    • pauseScheduler

      @Nonnull public SchedulerLock pauseScheduler()
      Pause scheduler so that it will not run any reactions next time triggerScheduler() is invoked. The scheduler will not resume scheduling reactions until the lock returned from this method is disposed.

      The intention of this method is to allow the user to manually batch multiple actions, before disposing the lock and allowing reactions to flow through the system. A typical use-case is when a large network packet is received and processed over multiple ticks but you only want the application to react once.

      If this is invoked from within a reaction then the current behaviour will continue to process any pending reactions until there is none left. However this behaviour should not be relied upon as it may result in an abort in the future.

      It should be noted that this is the one way where inconsistent state can creep into an Arez application. If an external action can trigger while the scheduler is paused. i.e. In the browser when an event-handler calls back from UI when the reactions have not run. Thus the event handler could be based on stale data. If this can occur the developer should

      Returns:
      a lock on scheduler.
    • setTaskInterceptor

      @OmitSymbol(unless="arez.enable_task_interceptor") public void setTaskInterceptor(@Nullable TaskInterceptor taskInterceptor)
      Specify a interceptor to use to wrap task execution in.
      Parameters:
      taskInterceptor - interceptor used to wrap task execution.
    • triggerScheduler

      public void triggerScheduler()
      Method invoked to trigger the scheduler to run any pending reactions. The scheduler will only be triggered if there is no transaction active. This method is typically used after one or more Observers have been created outside a transaction with the runImmediately flag set to false and the caller wants to force the observers to react. Otherwise the Observers will not be schedule until the next top-level transaction completes.
    • action

      public <T> T action(@Nonnull Function<T> executable) throws Throwable
      Execute the supplied executable in a transaction. The executable may throw an exception.
      Type Parameters:
      T - the type of return value.
      Parameters:
      executable - the executable.
      Returns:
      the value returned from the executable.
      Throws:
      Exception - if the executable throws an an exception.
      Throwable
    • action

      public <T> T action(@Nonnull Function<T> executable, int flags) throws Throwable
      Execute the supplied executable in a transaction. The executable may throw an exception.
      Type Parameters:
      T - the type of return value.
      Parameters:
      executable - the executable.
      flags - the flags for the action. The acceptable flags are defined in ActionFlags.
      Returns:
      the value returned from the executable.
      Throws:
      Exception - if the executable throws an an exception.
      Throwable
    • action

      public <T> T action(@Nullable String name, @Nonnull Function<T> executable) throws Throwable
      Execute the supplied executable in a transaction. The executable may throw an exception.
      Type Parameters:
      T - the type of return value.
      Parameters:
      name - the name of the action.
      executable - the executable.
      Returns:
      the value returned from the executable.
      Throws:
      Exception - if the executable throws an an exception.
      Throwable
    • action

      public <T> T action(@Nullable String name, @Nonnull Function<T> executable, int flags) throws Throwable
      Execute the supplied executable in a transaction. The executable may throw an exception.
      Type Parameters:
      T - the type of return value.
      Parameters:
      name - the name of the action.
      executable - the executable.
      flags - the flags for the action. The acceptable flags are defined in ActionFlags.
      Returns:
      the value returned from the executable.
      Throws:
      Exception - if the executable throws an an exception.
      Throwable
    • action

      public <T> T action(@Nullable String name, @Nonnull Function<T> executable, int flags, @Nullable Object[] parameters) throws Throwable
      Execute the supplied executable in a transaction. The executable may throw an exception.
      Type Parameters:
      T - the type of return value.
      Parameters:
      name - the name of the action.
      executable - the executable.
      flags - the flags for the action. The acceptable flags are defined in ActionFlags.
      parameters - the parameters if any. The parameters are only used to generate a spy event.
      Returns:
      the value returned from the executable.
      Throws:
      Exception - if the executable throws an an exception.
      Throwable
    • observe

      public <T> T observe(@Nonnull Observer observer, @Nonnull Function<T> observe) throws Throwable
      Execute the observe function with the specified Observer. The Observer must be created by the tracker(Procedure) methods. The observe function may throw an exception.
      Type Parameters:
      T - the type of return value.
      Parameters:
      observer - the Observer.
      observe - the observe function.
      Returns:
      the value returned from the observe function.
      Throws:
      Exception - if the observe function throws an an exception.
      Throwable
    • observe

      public <T> T observe(@Nonnull Observer observer, @Nonnull Function<T> observe, @Nullable Object[] parameters) throws Throwable
      Execute the observe function with the specified Observer. The Observer must be created by the tracker(Procedure) methods. The observe function may throw an exception.
      Type Parameters:
      T - the type of return value.
      Parameters:
      observer - the Observer.
      observe - the observe function.
      parameters - the parameters if any. The parameters are only used to generate a spy event.
      Returns:
      the value returned from the observe function.
      Throws:
      Exception - if the observe function throws an an exception.
      Throwable
    • safeAction

      public <T> T safeAction(@Nonnull SafeFunction<T> executable)
      Execute the supplied executable. The executable is should not throw an exception.
      Type Parameters:
      T - the type of return value.
      Parameters:
      executable - the executable.
      Returns:
      the value returned from the executable.
    • safeAction

      public <T> T safeAction(@Nonnull SafeFunction<T> executable, int flags)
      Execute the supplied executable. The executable is should not throw an exception.
      Type Parameters:
      T - the type of return value.
      Parameters:
      executable - the executable.
      flags - the flags for the action.
      Returns:
      the value returned from the executable.
    • safeAction

      public <T> T safeAction(@Nullable String name, @Nonnull SafeFunction<T> executable)
      Execute the supplied executable. The executable is should not throw an exception.
      Type Parameters:
      T - the type of return value.
      Parameters:
      name - the name of the action.
      executable - the executable.
      Returns:
      the value returned from the executable.
    • safeAction

      public <T> T safeAction(@Nullable String name, @Nonnull SafeFunction<T> executable, int flags)
      Execute the supplied executable. The executable is should not throw an exception.
      Type Parameters:
      T - the type of return value.
      Parameters:
      name - the name of the action.
      executable - the executable.
      flags - the flags for the action. The acceptable flags are defined in ActionFlags.
      Returns:
      the value returned from the executable.
    • safeAction

      public <T> T safeAction(@Nullable String name, @Nonnull SafeFunction<T> executable, int flags, @Nullable Object[] parameters)
      Execute the supplied executable. The executable is should not throw an exception.
      Type Parameters:
      T - the type of return value.
      Parameters:
      name - the name of the action.
      executable - the executable.
      flags - the flags for the action. The acceptable flags are defined in ActionFlags.
      parameters - the parameters if any. The parameters are only used to generate a spy event.
      Returns:
      the value returned from the executable.
    • safeObserve

      public <T> T safeObserve(@Nonnull Observer observer, @Nonnull SafeFunction<T> observe)
      Execute the observe function with the specified Observer. The Observer must be created by the tracker(Procedure) methods. The observe function should not throw an exception.
      Type Parameters:
      T - the type of return value.
      Parameters:
      observer - the Observer.
      observe - the observe function.
      Returns:
      the value returned from the observe function.
    • safeObserve

      public <T> T safeObserve(@Nonnull Observer observer, @Nonnull SafeFunction<T> observe, @Nullable Object[] parameters)
      Execute the observe function with the specified Observer. The Observer must be created by the tracker(Procedure) methods. The observe function should not throw an exception.
      Type Parameters:
      T - the type of return value.
      Parameters:
      observer - the Observer.
      observe - the observe function.
      parameters - the parameters if any. The parameters are only used to generate a spy event.
      Returns:
      the value returned from the observe function.
    • action

      public void action(@Nonnull Procedure executable) throws Throwable
      Execute the supplied executable in a transaction. The executable may throw an exception.
      Parameters:
      executable - the executable.
      Throws:
      Throwable - if the procedure throws an an exception.
    • action

      public void action(@Nonnull Procedure executable, int flags) throws Throwable
      Execute the supplied executable in a transaction. The executable may throw an exception.
      Parameters:
      executable - the executable.
      flags - the flags for the action. The acceptable flags are defined in ActionFlags.
      Throws:
      Throwable - if the procedure throws an an exception.
    • action

      public void action(@Nullable String name, @Nonnull Procedure executable) throws Throwable
      Execute the supplied executable in a transaction. The executable may throw an exception.
      Parameters:
      name - the name of the action.
      executable - the executable.
      Throws:
      Throwable - if the procedure throws an an exception.
    • action

      public void action(@Nullable String name, @Nonnull Procedure executable, int flags) throws Throwable
      Execute the supplied executable in a transaction. The executable may throw an exception.
      Parameters:
      name - the name of the action.
      executable - the executable.
      flags - the flags for the action. The acceptable flags are defined in ActionFlags.
      Throws:
      Throwable - if the procedure throws an an exception.
    • action

      public void action(@Nullable String name, @Nonnull Procedure executable, int flags, @Nullable Object[] parameters) throws Throwable
      Execute the supplied executable in a transaction. The executable may throw an exception.
      Parameters:
      name - the name of the action.
      executable - the executable.
      flags - the flags for the action. The acceptable flags are defined in ActionFlags.
      parameters - the parameters if any. The parameters are only used to generate a spy event.
      Throws:
      Throwable - if the procedure throws an an exception.
    • observe

      public void observe(@Nonnull Observer observer, @Nonnull Procedure observe) throws Throwable
      Execute the observe function with the specified Observer. The Observer must be created by the tracker(Procedure) methods. The observe function may throw an exception.
      Parameters:
      observer - the Observer.
      observe - the observe function.
      Throws:
      Exception - if the observe function throws an an exception.
      Throwable
    • observe

      public void observe(@Nonnull Observer observer, @Nonnull Procedure observe, @Nullable Object[] parameters) throws Throwable
      Execute the observe function with the specified Observer. The Observer must be created by the tracker(Procedure) methods. The observe function may throw an exception.
      Parameters:
      observer - the Observer.
      observe - the observe function.
      parameters - the parameters if any. The parameters are only used to generate a spy event.
      Throws:
      Exception - if the observe function throws an an exception.
      Throwable
    • safeAction

      public void safeAction(@Nonnull SafeProcedure executable)
      Execute the supplied executable in a transaction.
      Parameters:
      executable - the executable.
    • safeAction

      public void safeAction(@Nonnull SafeProcedure executable, int flags)
      Execute the supplied executable in a transaction.
      Parameters:
      executable - the executable.
      flags - the flags for the action. The acceptable flags are defined in ActionFlags.
    • safeAction

      public void safeAction(@Nullable String name, @Nonnull SafeProcedure executable)
      Execute the supplied executable in a transaction.
      Parameters:
      name - the name of the action.
      executable - the executable.
    • safeAction

      public void safeAction(@Nullable String name, @Nonnull SafeProcedure executable, int flags)
      Execute the supplied executable in a transaction.
      Parameters:
      name - the name of the action.
      executable - the executable.
      flags - the flags for the action. The acceptable flags are defined in ActionFlags.
    • safeAction

      public void safeAction(@Nullable String name, @Nonnull SafeProcedure executable, int flags, @Nullable Object[] parameters)
      Execute the supplied executable in a transaction.
      Parameters:
      name - the name of the action.
      executable - the executable.
      flags - the flags for the action. The acceptable flags are defined in ActionFlags.
      parameters - the parameters if any. The parameters are only used to generate a spy event.
    • safeObserve

      public void safeObserve(@Nonnull Observer observer, @Nonnull SafeProcedure observe)
      Execute the observe function with the specified Observer. The Observer must be created by the tracker(Procedure) methods. The observe function should not throw an exception.
      Parameters:
      observer - the Observer.
      observe - the observe function.
    • safeObserve

      public void safeObserve(@Nonnull Observer observer, @Nonnull SafeProcedure observe, @Nullable Object[] parameters)
      Execute the observe function with the specified Observer. The Observer must be created by the tracker(Procedure) methods. The observe function should not throw an exception.
      Parameters:
      observer - the Observer.
      observe - the observe function.
      parameters - the parameters if any. The parameters are only used to generate a spy event.
    • registerLocator

      @OmitSymbol(unless="arez.enable_references") @Nonnull public Disposable registerLocator(@Nonnull Locator locator)
      Register an entity locator to use to resolve references. The Locator must not already be registered. This should not be invoked unless Arez.areReferencesEnabled() returns true.
      Parameters:
      locator - the Locator to register.
      Returns:
      the disposable to dispose to deregister locator.
    • locator

      @OmitSymbol(unless="arez.enable_references") @Nonnull public Locator locator()
      Return the locator that can be used to resolve references. This should not be invoked unless Arez.areReferencesEnabled() returns true.
      Returns:
      the Locator.
    • addObserverErrorHandler

      @OmitSymbol(unless="arez.enable_observer_error_handlers") public void addObserverErrorHandler(@Nonnull ObserverErrorHandler handler)
      Add error handler to the list of error handlers called. The handler should not already be in the list. This method should NOT be called if Arez.areObserverErrorHandlersEnabled() returns false.
      Parameters:
      handler - the error handler.
    • removeObserverErrorHandler

      @OmitSymbol(unless="arez.enable_observer_error_handlers") public void removeObserverErrorHandler(@Nonnull ObserverErrorHandler handler)
      Remove error handler from list of existing error handlers. The handler should already be in the list. This method should NOT be called if Arez.areObserverErrorHandlersEnabled() returns false.
      Parameters:
      handler - the error handler.
    • getSpy

      @Nonnull public Spy getSpy()
      Return the spy associated with context. This method should not be invoked unless Arez.areSpiesEnabled() returns true.
      Returns:
      the spy associated with context.