Class ArezContext
-
Method Summary
Modifier and TypeMethodDescription<T> T
Execute the supplied executable in a transaction.<T> T
Execute the supplied executable in a transaction.void
Execute the supplied executable in a transaction.void
Execute the supplied executable in a transaction.<T> T
Execute the supplied executable in a transaction.<T> T
Execute the supplied executable in a transaction.<T> T
Execute the supplied executable in a transaction.void
Execute the supplied executable in a transaction.void
Execute the supplied executable in a transaction.void
Execute the supplied executable in a transaction.void
Add error handler to the list of error handlers called.Create a component with the specified parameters and return it.Create a component with the specified parameters and return it.component
(String type, Object id, String name, SafeProcedure preDispose) Create a component with the specified parameters and return it.component
(String type, Object id, String name, SafeProcedure preDispose, SafeProcedure postDispose) Create a component with the specified parameters and return it.<T> ComputableValue<T>
computable
(Component component, String name, SafeFunction<T> function) Create a ComputableValue with specified parameters.<T> ComputableValue<T>
computable
(Component component, String name, SafeFunction<T> function, int flags) Create a ComputableValue with specified parameters.<T> ComputableValue<T>
computable
(Component component, String name, SafeFunction<T> function, Procedure onActivate, Procedure onDeactivate) Create a ComputableValue with specified parameters.<T> ComputableValue<T>
computable
(Component component, String name, SafeFunction<T> function, Procedure onActivate, Procedure onDeactivate, int flags) Create a ComputableValue with specified parameters.<T> ComputableValue<T>
computable
(SafeFunction<T> function) Create a ComputableValue with specified parameters.<T> ComputableValue<T>
computable
(SafeFunction<T> function, int flags) Create a ComputableValue with specified parameters.<T> ComputableValue<T>
computable
(String name, SafeFunction<T> function) Create a ComputableValue with specified parameters.<T> ComputableValue<T>
computable
(String name, SafeFunction<T> function, int flags) Create a ComputableValue with specified parameters.<T> ComputableValue<T>
computable
(String name, SafeFunction<T> function, Procedure onActivate, Procedure onDeactivate) Create a ComputableValue with specified parameters.<T> ComputableValue<T>
computable
(String name, SafeFunction<T> function, Procedure onActivate, Procedure onDeactivate, int flags) Create a ComputableValue with specified parameters.getSpy()
Return the spy associated with context.boolean
isComponentPresent
(String type, Object id) Return true if the component identified by type and id has been defined in context.boolean
Return true if there is a transaction in progress calculating a computable value.boolean
Return true if there is a read-only transaction in progress.boolean
Return true if there is a read-write transaction in progress.boolean
Return true if the scheduler is currently executing tasks.boolean
Return true if the scheduler is paused.boolean
Return true if there is a tracking transaction in progress.boolean
Return true if there is a transaction in progress.locator()
Return the locator that can be used to resolve references.<T> ObservableValue<T>
Create an ObservableValue synthesizing name if required.<T> ObservableValue<T>
observable
(Component component, String name) Create an ObservableValue.<T> ObservableValue<T>
observable
(Component component, String name, PropertyAccessor<T> accessor) Create an ObservableValue.<T> ObservableValue<T>
observable
(Component component, String name, PropertyAccessor<T> accessor, PropertyMutator<T> mutator) Create an ObservableValue.<T> ObservableValue<T>
observable
(String name) Create an ObservableValue with the specified name.<T> ObservableValue<T>
observable
(String name, PropertyAccessor<T> accessor, PropertyMutator<T> mutator) Create an ObservableValue.<T> T
Execute the observe function with the specified Observer.<T> T
Execute the observe function with the specified Observer.void
Execute the observe function with the specified Observer.void
Execute the observe function with the specified Observer.Create an "autorun" observer that reschedules observed procedure when dependency updates occur.Create an "autorun" observer that reschedules observed procedure when dependency updates occur.Create an observer.Create an observer.Create an "autorun" observer that reschedules observed procedure when dependency updates occur.Create an "autorun" observer that reschedules observed procedure when dependency updates occur.Create an observer.Create an observer.Create an "autorun" observer that reschedules observed procedure when dependency updates occur.Create an "autorun" observer that reschedules observed procedure when dependency updates occur.Create an observer.Create an observer.Pause scheduler so that it will not run any reactions next timetriggerScheduler()
is invoked.registerLocator
(Locator locator) Register an entity locator to use to resolve references.void
Remove error handler from list of existing error handlers.<T> T
safeAction
(SafeFunction<T> executable) Execute the supplied executable.<T> T
safeAction
(SafeFunction<T> executable, int flags) Execute the supplied executable.void
safeAction
(SafeProcedure executable) Execute the supplied executable in a transaction.void
safeAction
(SafeProcedure executable, int flags) Execute the supplied executable in a transaction.<T> T
safeAction
(String name, SafeFunction<T> executable) Execute the supplied executable.<T> T
safeAction
(String name, SafeFunction<T> executable, int flags) Execute the supplied executable.<T> T
safeAction
(String name, SafeFunction<T> executable, int flags, Object[] parameters) Execute the supplied executable.void
safeAction
(String name, SafeProcedure executable) Execute the supplied executable in a transaction.void
safeAction
(String name, SafeProcedure executable, int flags) Execute the supplied executable in a transaction.void
safeAction
(String name, SafeProcedure executable, int flags, Object[] parameters) Execute the supplied executable in a transaction.<T> T
safeObserve
(Observer observer, SafeFunction<T> observe) Execute the observe function with the specified Observer.<T> T
safeObserve
(Observer observer, SafeFunction<T> observe, Object[] parameters) Execute the observe function with the specified Observer.void
safeObserve
(Observer observer, SafeProcedure observe) Execute the observe function with the specified Observer.void
safeObserve
(Observer observer, SafeProcedure observe, Object[] parameters) Execute the observe function with the specified Observer.void
setTaskInterceptor
(TaskInterceptor taskInterceptor) Specify a interceptor to use to wrap task execution in.task
(SafeProcedure work) Create and queue a task to be executed by the runtime.task
(SafeProcedure work, int flags) Create and queue a task to be executed by the runtime.task
(String name, SafeProcedure work) Create and queue a task to be executed by the runtime.task
(String name, SafeProcedure work, int flags) Create and queue a task to be executed by the runtime.Create a tracking observer.Create a tracking observer.Create a tracking observer.Create a tracking observer.Create a tracking observer.Create a tracking observer.void
Method invoked to trigger the scheduler to run any pending reactions.
-
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 ifArez.areNativeComponentsEnabled()
returns true. This method should not be invoked ifisComponentPresent(String, Object)
returns true for the parameters. The caller should invokeComponent.complete()
on the returned component as soon as the component definition has completed.- Parameters:
type
- the component type.id
- the component id.- Returns:
- the created component.
-
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 ifArez.areNativeComponentsEnabled()
returns true. This method should not be invoked ifisComponentPresent(String, Object)
returns true for the parameters. The caller should invokeComponent.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 ifArez.areNamesEnabled()
returns false.- Returns:
- the created component.
-
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 ifArez.areNativeComponentsEnabled()
returns true. This method should not be invoked ifisComponentPresent(String, Object)
returns true for the parameters. The caller should invokeComponent.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 ifArez.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:
- the created component.
-
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 ifArez.areNativeComponentsEnabled()
returns true. This method should not be invoked ifisComponentPresent(String, Object)
returns true for the parameters. The caller should invokeComponent.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 ifArez.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:
- the created component.
-
computable
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
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 inComputableValue.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 inComputableValue.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 unlessArez.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 unlessArez.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 inComputableValue.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 unlessArez.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 inComputableValue.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 unlessArez.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 inComputableValue.Flags
.- Returns:
- the ComputableValue instance.
-
observer
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
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 inObserver.Flags
.- Returns:
- the new Observer.
-
observer
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
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 inObserver.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 ifArez.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 ifArez.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 inObserver.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 theobserve
oronDepsChange
parameter.- Parameters:
component
- the component containing the observer if any. Should be null ifArez.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 callingObserver.schedule()
at some point.- Returns:
- the new Observer.
-
observer
Create an observer. The user must pass either theobserve
oronDepsChange
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 callingObserver.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 theobserve
oronDepsChange
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 callingObserver.schedule()
at some point.flags
- the flags used to create the observer. The acceptable flags are defined inObserver.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 theobserve
oronDepsChange
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 callingObserver.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 theobserve
oronDepsChange
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 callingObserver.schedule()
at some point.flags
- the flags used to create the observer. The acceptable flags are defined inObserver.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 theobserve
oronDepsChange
or both parameters.- Parameters:
component
- the component containing the observer if any. Should be null ifArez.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 callingObserver.schedule()
at some point.flags
- the flags used to create the observer. The acceptable flags are defined inObserver.Flags
.- Returns:
- the new Observer.
-
tracker
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 asobserve(Observer, Function)
.- Parameters:
onDepsChange
- the hook invoked when dependencies changed.- Returns:
- the new Observer.
-
tracker
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 asobserve(Observer, Function)
.- Parameters:
onDepsChange
- the hook invoked when dependencies changed.flags
- the flags used to create the observer. The acceptable flags are defined inObserver.Flags
.- Returns:
- the new Observer.
-
tracker
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 asobserve(Observer, Function)
.- Parameters:
name
- the name of the observer.onDepsChange
- the hook invoked when dependencies changed.- Returns:
- the new Observer.
-
tracker
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 asobserve(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 inObserver.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 asobserve(Observer, Function)
.- Parameters:
component
- the component containing the observer if any. Should be null ifArez.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 asobserve(Observer, Procedure)
.- Parameters:
component
- the component containing the observer, if any. Should be null ifArez.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 inObserver.Flags
.- Returns:
- the new Observer.
-
observable
Create an ObservableValue synthesizing name if required.- Type Parameters:
T
- the type of observable.- Returns:
- the new ObservableValue.
-
observable
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 ifArez.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 ifArez.areNamesEnabled()
returns true, null otherwise.accessor
- the accessor for observable. Should be null ifArez.arePropertyIntrospectorsEnabled()
returns false, may be non-null otherwise.mutator
- the mutator for observable. Should be null ifArez.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 ifArez.areNativeComponentsEnabled()
returns false.name
- the name of the observable. Should be non-null ifArez.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 ifArez.areNativeComponentsEnabled()
returns false.name
- the name of the observable. Should be non-null ifArez.areNamesEnabled()
returns true, null otherwise.accessor
- the accessor for observable. Should be null ifArez.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 ifArez.areNativeComponentsEnabled()
returns false.name
- the name of the observable. Should be non-null ifArez.areNamesEnabled()
returns true, null otherwise.accessor
- the accessor for observable. Should be null ifArez.arePropertyIntrospectorsEnabled()
returns false, may be non-null otherwise.mutator
- the mutator for observable. Should be null ifArez.arePropertyIntrospectorsEnabled()
returns false, may be non-null otherwise.- Returns:
- the new ObservableValue.
-
task
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
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 ifArez.areNamesEnabled()
returnsfalse
.work
- the representation of the task to execute.- Returns:
- the new task.
-
task
Create and queue a task to be executed by the runtime. If the scheduler is not running and theTask.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 the task. Valid flags include PRIORITY_* flags, DISPOSE_ON_COMPLETE and RUN_* flags.- Returns:
- the new task.
-
task
Create and queue a task to be executed by the runtime. If the scheduler is not running and theTask.Flags.RUN_LATER
flag has not been supplied then the scheduler will be triggered.- Parameters:
name
- the name of the task. Must be null ifArez.areNamesEnabled()
returnsfalse
.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
Return true if the scheduler is currently executing tasks.- Returns:
- true if the scheduler is currently executing tasks.
-
isTransactionActive
Return true if there is a transaction in progress.- Returns:
- true if there is a transaction in progress.
-
isTrackingTransactionActive
Return true if there is a tracking transaction in progress. A tracking transaction is one created by anObserver
via theobserver(Procedure)
ortracker(Procedure)
methods or a computable via thecomputable(SafeFunction)
function.- Returns:
- true if there is a tracking transaction in progress.
-
isComputableTransactionActive
Return true if there is a transaction in progress calculating a computable value. The transaction is one created for anComputableValue
via thecomputable(SafeFunction)
functions.- Returns:
- true, if there is a transaction in progress calculating a computable value.
-
isReadWriteTransactionActive
Return true if there is a read-write transaction in progress.- Returns:
- true if there is a read-write transaction in progress.
-
isReadOnlyTransactionActive
Return true if there is a read-only transaction in progress.- Returns:
- true if there is a read-only transaction in progress.
-
isSchedulerPaused
Return true if the scheduler is paused. True means thatpauseScheduler()
has been called one or more times and the lock not disposed.- Returns:
- true if the scheduler is paused, false otherwise.
-
pauseScheduler
Pause scheduler so that it will not run any reactions next timetriggerScheduler()
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
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
Execute the supplied executable in a transaction. The executable may throw an exception. -
action
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 inActionFlags
.- Returns:
- the value returned from the executable.
- Throws:
Exception
- if the executable throws an an exception.Throwable
-
action
Execute the supplied executable in a transaction. The executable may throw an exception. -
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 inActionFlags
.- 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 inActionFlags
.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
Execute the observe function with the specified Observer. The Observer must be created by thetracker(Procedure)
methods. The observe function may throw an exception. -
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 thetracker(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
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
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
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
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 inActionFlags
.- 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 inActionFlags
.parameters
- the parameters if any. The parameters are only used to generate a spy event.- Returns:
- the value returned from the executable.
-
safeObserve
Execute the observe function with the specified Observer. The Observer must be created by thetracker(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 thetracker(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
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
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 inActionFlags
.- Throws:
Throwable
- if the procedure throws an an exception.
-
action
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 inActionFlags
.- 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 inActionFlags
.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
Execute the observe function with the specified Observer. The Observer must be created by thetracker(Procedure)
methods. The observe function may throw an exception. -
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 thetracker(Procedure)
methods. The observe function may throw an exception. -
safeAction
Execute the supplied executable in a transaction.- Parameters:
executable
- the executable.
-
safeAction
Execute the supplied executable in a transaction.- Parameters:
executable
- the executable.flags
- the flags for the action. The acceptable flags are defined inActionFlags
.
-
safeAction
Execute the supplied executable in a transaction.- Parameters:
name
- the name of the action.executable
- the executable.
-
safeAction
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 inActionFlags
.
-
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 inActionFlags
.parameters
- the parameters if any. The parameters are only used to generate a spy event.
-
safeObserve
Execute the observe function with the specified Observer. The Observer must be created by thetracker(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 thetracker(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
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 ifArez.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 ifArez.areObserverErrorHandlersEnabled()
returns false.- Parameters:
handler
- the error handler.
-
getSpy
Return the spy associated with context. This method should not be invoked unlessArez.areSpiesEnabled()
returns true.- Returns:
- the spy associated with context.
-