RxCommand<TParam, TRESULT> class
RxCommand
capsules a given handler function that can then be executed by its execute
method.
The result of this method is then published through its results
Observable (Observable wrap Dart Streams).
Additionally it offers Observables for it's current execution state, fs the command can be executed and for
all possibly thrown exceptions during command execution.
An RxCommand
is a generic class of type RxCommand<TParam, TRESULT>
where TPARAM
is the type of data that is passed when calling execute
and
TResult
denotes the return type of the handler function. To signal that
a handler doesn't take a parameter or returns a value use the dummy type Null
- Implemented by
Constructors
Properties
- canExecute → Observable<bool>
-
Observable stream that issues a bool on any change of the current executable state of the command.
Meaning if the command cann be executed or not. This will issue
false
while the command executes but also if the command receives a false from the canExecute Observable that you can pass when creating the Commandread-only - isExecuting → Observable<bool>
-
Observable stream that issues a bool on any execution state change of the command
read-only
- results → Observable<TRESULT>
-
Observable stream that outputs any result from the called handler function. If the handler function has void return type
it will still output one
Null
item so that you can listen for the end of the execution.read-only - thrownExceptions → Observable<Exception>
-
When subribing to
thrownExceptions
you will every excetpion that was thrown in your handler function as an event on this Observable. If no subscription exists the Exception will be rethrownread-only - hashCode → int
-
The hash code for this object. [...]
read-only, inherited
- runtimeType → Type
-
A representation of the runtime type of the object.
read-only, inherited
Methods
-
dispose(
) → void - If you don't need a command any longer it is a good practise to dispose it to make sure all stream subsriptions are cancelled to prevent memory leaks
-
execute(
[TParam param ]) → dynamic - Calls the wrapped handler function with an option input parameter
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed. [...]
inherited
-
toString(
) → String -
Returns a string representation of this object.
inherited
Operators
-
operator ==(
dynamic other) → bool -
The equality operator. [...]
inherited
Static Methods
-
createAsync(
AsyncAction action, [ Observable<bool> canExecute ]) → RxCommand<Null, Null> -
Creates a RxCommand for an asynchronous handler function with no parameter and no return type
action
: handler functioncanExecute
: observable that can bve used to enable/diable the command based on some other state change if omitted the command can be executed always except it's already executing -
createAsync1<TParam>(
AsyncAction1<TParam> action, [ Observable<bool> canExecute ]) → RxCommand<TParam, Null> -
Creates a RxCommand for an asynchronous handler function with one parameter and no return type
action
: handler functioncanExecute
: observable that can bve used to enable/diable the command based on some other state change if omitted the command can be executed always except it's already executing -
createAsync2<TResult>(
AsyncFunc<TResult> func, [ Observable<bool> canExecute ]) → RxCommand<Null, TResult> -
Creates a RxCommand for an asynchronous handler function with no parameter that returns a value
func
: handler functioncanExecute
: observable that can bve used to enable/diable the command based on some other state change if omitted the command can be executed always except it's already executing -
createAsync3<TParam, TResult>(
AsyncFunc1<TParam, TResult> func, [ Observable<bool> canExecute ]) → RxCommand<TParam, TResult> -
Creates a RxCommand for an asynchronous handler function with parameter that returns a value
func
: handler functioncanExecute
: observable that can bve used to enable/diable the command based on some other state change if omitted the command can be executed always except it's already executing -
createSync(
Action action, [ Observable<bool> canExecute ]) → RxCommand<Null, Null> -
Creates a RxCommand for a synchronous handler function with no parameter and no return type
action
: handler functioncanExecute
: observable that can bve used to enable/diable the command based on some other state change if omitted the command can be executed always except it's already executing -
createSync1<TParam>(
Action1<TParam> action, [ Observable<bool> canExecute ]) → RxCommand<TParam, Null> -
Creates a RxCommand for a synchronous handler function with one parameter and no return type
action
: handler functioncanExecute
: observable that can bve used to enable/diable the command based on some other state change if omitted the command can be executed always except it's already executing -
createSync2<TResult>(
Func<TResult> func, [ Observable<bool> canExecute ]) → RxCommand<Null, TResult> -
Creates a RxCommand for a synchronous handler function with no parameter that returns a value
func
: handler functioncanExecute
: observable that can bve used to enable/diable the command based on some other state change if omitted the command can be executed always except it's already executing -
createSync3<TParam, TResult>(
Func1<TParam, TResult> func, [ Observable<bool> canExecute ]) → RxCommand<TParam, TResult> -
Creates a RxCommand for a synchronous handler function with parameter that returns a value
func
: handler functioncanExecute
: observable that can bve used to enable/diable the command based on some other state change if omitted the command can be executed always except it's already executing