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 Observable (Observable wrap Dart Streams) Additionally it offers Observables for it's current execution state, if the command can be executed and for all possibly thrown exceptions during command execution.
RxCommand implements the Observable
interface so you can listen directly to the RxCommand which emits the
results of the wrapped function. If this function has a void
return type
it will still output one void
item so that you can listen for the end of the execution.
The results Observable emits CommandResult<TRESULT> which is often easier in combaination with Flutter StreamBuilder
because you have all state information at one place.
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 no value use the type void
- Implementers
Constructors
-
RxCommand(Subject<
TResult> _resultsSubject, Observable<bool> canExecuteRestriction, bool _emitLastResult, bool _resultSubjectIsBehaviourSubject, TResult lastResult)
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
- lastResult ↔ TResult
-
The result of the last sucessful call to execute. This is especialls handy to use as
initialData
of FlutterStreambuilder
read / write -
next
→ Future<
TResult> -
This property is a utility which allows us to chain RxCommands together.
read-only
-
results
→ Observable<
CommandResult< TResult> > -
emits CommandResult<TRESULT> the combined state of the commane, which is often easier in combination with Flutter
StreamBuilder
because you have all state information at one place.read-only - throwExceptions ↔ bool
-
By default
RxCommand
will catch all exceptions during exceution of the command. And publish them on.thrownExceptions
and in theCommandResult
. If don't want this and have exceptions thrown, set this to true.read / write - thrownExceptions → Observable
-
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 -
first
→ AsObservableFuture<
TResult> -
The first element of this stream. [...]
read-only, inherited
- hashCode → int
-
The hash code for this object. [...]
read-only, inherited
- isBroadcast → bool
-
Whether this stream is a broadcast stream.
read-only, inherited
-
isEmpty
→ AsObservableFuture<
bool> -
Whether this stream contains any elements. [...]
read-only, inherited
-
last
→ AsObservableFuture<
TResult> -
The last element of this stream. [...]
read-only, inherited
-
length
→ AsObservableFuture<
int> -
The number of elements in this stream. [...]
read-only, inherited
- runtimeType → Type
-
A representation of the runtime type of the object.
read-only, inherited
-
single
→ AsObservableFuture<
TResult> -
The single element of this stream. [...]
read-only, inherited
Methods
-
call(
[TParam param ]) → void -
This makes RxCommand a callable class, so instead of
myCommand.exceute()
you can writemyCommand()
-
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 ]) → void - Calls the wrapped handler function with an option input parameter
-
any(
bool test(T element)) → AsObservableFuture< bool> -
Checks whether
test
accepts any element provided by this stream. [...]inherited -
asBroadcastStream(
{void onListen(StreamSubscription< T> subscription), void onCancel(StreamSubscription<T> subscription) }) → Observable<TResult> -
Returns a multi-subscription stream that produces the same events as this. [...]
inherited
-
asyncExpand<
S> (Stream< S> mapper(T value)) → Observable<S> -
Maps each emitted item to a new
Stream
using the given mapper, then subscribes to each new stream one after the next until all values are emitted. [...]inherited -
asyncMap<
S> (FutureOr< S> convert(T value)) → Observable<S> -
Creates an Observable with each data event of this stream asynchronously
mapped to a new event. [...]
inherited
-
buffer(
Stream window) → Observable< List< TResult> > -
Creates an Observable where each item is a
List
containing the items from the source sequence. [...]inherited -
bufferCount(
int count, [ int startBufferEvery = 0 ]) → Observable< List< TResult> > -
Buffers a number of values from the source Observable by
count
then emits the buffer and clears it, and starts a new buffer eachstartBufferEvery
values. IfstartBufferEvery
is not provided, then new buffers are started immediately at the start of the source and when each buffer closes and is emitted. [...]inherited -
bufferTest(
bool onTestHandler(T event)) → Observable< List< TResult> > -
Creates an Observable where each item is a
List
containing the items from the source sequence, batched whenever test passes. [...]inherited -
bufferTime(
Duration duration) → Observable< List< TResult> > -
Creates an Observable where each item is a
List
containing the items from the source sequence, sampled on a time frame withduration
. [...]inherited -
cast<
R> () → Observable< R> -
Adapt this stream to be a
Stream<R>
. [...]inherited -
concatMap<
S> (Stream< S> mapper(T value)) → Observable<S> -
Maps each emitted item to a new
Stream
using the given mapper, then subscribes to each new stream one after the next until all values are emitted. [...]inherited -
concatWith(
Iterable< Stream< other) → Observable<TResult> >TResult> -
Returns an Observable that emits all items from the current Observable,
then emits all items from the given observable, one after the next. [...]
inherited
-
contains(
Object needle) → AsObservableFuture< bool> -
Returns whether
needle
occurs in the elements provided by this stream. [...]inherited -
debounce(
Stream window(T event)) → Observable< TResult> -
Transforms a
Stream
so that will only emit items from the source sequence if awindow
has completed, without the source sequence emitting another item. [...]inherited -
debounceTime(
Duration duration) → Observable< TResult> -
Transforms a
Stream
so that will only emit items from the source sequence whenever the time span defined byduration
passes, without the source sequence emitting another item. [...]inherited -
defaultIfEmpty(
TResult defaultValue) → Observable< TResult> -
Emit items from the source Stream, or a single default item if the source
Stream emits nothing. [...]
inherited
-
delay(
Duration duration) → Observable< TResult> -
The Delay operator modifies its source Observable by pausing for
a particular increment of time (that you specify) before emitting
each of the source Observable’s items.
This has the effect of shifting the entire sequence of items emitted
by the Observable forward in time by that specified increment. [...]
inherited
-
dematerialize<
S> () → Observable< S> -
Converts the onData, onDone, and onError
Notification
objects from a materialized stream into normal onData, onDone, and onError events. [...]inherited -
distinct(
[bool equals(T previous, T next) ]) → Observable< TResult> -
WARNING: More commonly known as distinctUntilChanged in other Rx
implementations. Creates an Observable where data events are skipped if
they are equal to the previous data event. [...]
inherited
-
distinctUnique(
{bool equals(T e1, T e2), int hashCode(T e) }) → Observable< TResult> -
WARNING: More commonly known as distinct in other Rx implementations.
Creates an Observable where data events are skipped if they have already
been emitted before. [...]
inherited
-
doOnCancel(
void onCancel()) → Observable< TResult> -
Invokes the given callback function when the stream subscription is
cancelled. Often called doOnUnsubscribe or doOnDispose in other
implementations. [...]
inherited
-
doOnData(
void onData(T event)) → Observable< TResult> -
Invokes the given callback function when the stream emits an item. In
other implementations, this is called doOnNext. [...]
inherited
-
doOnDone(
void onDone()) → Observable< TResult> -
Invokes the given callback function when the stream finishes emitting
items. In other implementations, this is called doOnComplete(d). [...]
inherited
-
doOnEach(
void onEach(Notification< T> notification)) → Observable<TResult> -
Invokes the given callback function when the stream emits data, emits
an error, or emits done. The callback receives a
Notification
object. [...]inherited -
doOnError(
Function onError) → Observable< TResult> -
Invokes the given callback function when the stream emits an error. [...]
inherited
-
doOnListen(
void onListen()) → Observable< TResult> -
Invokes the given callback function when the stream is first listened to. [...]
inherited
-
doOnPause(
void onPause(Future resumeSignal)) → Observable< TResult> -
Invokes the given callback function when the stream subscription is
paused. [...]
inherited
-
doOnResume(
void onResume()) → Observable< TResult> -
Invokes the given callback function when the stream subscription
resumes receiving items. [...]
inherited
-
drain<
S> ([S futureValue ]) → AsObservableFuture< S> -
Discards all data on this stream, but signals when it is done or an error
occurred. [...]
inherited
-
elementAt(
int index) → AsObservableFuture< TResult> -
Returns the value of the
index
th data event of this stream. [...]inherited -
every(
bool test(T element)) → AsObservableFuture< bool> -
Checks whether
test
accepts all elements provided by this stream. [...]inherited -
exhaustMap<
S> (Stream< S> mapper(T value)) → Observable<S> -
Converts items from the source stream into a new Stream using a given
mapper. It ignores all items from the source stream until the new stream
completes. [...]
inherited
-
expand<
S> (Iterable< S> convert(T value)) → Observable<S> -
Creates an Observable from this stream that converts each element into
zero or more events. [...]
inherited
-
firstWhere(
bool test(T element), { dynamic defaultValue(), TResult orElse() }) → AsObservableFuture< TResult> -
Finds the first element of this stream matching
test
. [...]inherited -
flatMap<
S> (Stream< S> mapper(T value)) → Observable<S> -
Converts each emitted item into a new Stream using the given mapper
function. The newly created Stream will be be listened to and begin
emitting items downstream. [...]
inherited
-
flatMapIterable<
S> (Stream< Iterable< mapper(T value)) → Observable<S> >S> -
Converts each item into a new Stream. The Stream must return an
Iterable. Then, each item from the Iterable will be emitted one by one. [...]
inherited
-
fold<
S> (S initialValue, S combine(S previous, T element)) → AsObservableFuture< S> -
Combines a sequence of values by repeatedly applying
combine
. [...]inherited -
forEach(
void action(T element)) → AsObservableFuture -
Executes
action
on each element of this stream. [...]inherited -
groupBy<
S> (S grouper(T value)) → Observable< GroupByObservable< TResult, S> > -
The GroupBy operator divides an
Observable
that emits items into anObservable
that emitsGroupByObservable
, each one of which emits some subset of the items from the original sourceObservable
. [...]inherited -
handleError(
Function onError, { bool test(dynamic error) }) → Observable< TResult> -
Creates a wrapper Stream that intercepts some errors from this stream. [...]
inherited
-
ignoreElements(
) → Observable< TResult> -
Creates an Observable where all emitted items are ignored, only the
error / completed notifications are passed [...]
inherited
-
interval(
Duration duration) → Observable< TResult> -
Creates an Observable that emits each item in the Stream after a given
duration. [...]
inherited
-
join(
[String separator = "" ]) → AsObservableFuture< String> -
Combines the string representation of elements into a single string. [...]
inherited
-
lastWhere(
bool test(T element), { Object defaultValue(), TResult orElse() }) → AsObservableFuture< TResult> -
Finds the last element in this stream matching
test
. [...]inherited -
listen(
void onData(T event), { Function onError, void onDone(), bool cancelOnError }) → StreamSubscription< TResult> -
Adds a subscription to this stream. Returns a
StreamSubscription
which handles events from the stream using the providedonData
,onError
andonDone
handlers. [...]inherited -
map<
S> (S convert(T event)) → Observable< S> -
Maps values from a source sequence through a function and emits the
returned values. [...]
inherited
-
mapTo<
S> (S value) → Observable< S> -
Emits the given constant value on the output Observable every time the source Observable emits a value. [...]
inherited
-
materialize(
) → Observable< Notification< TResult> > -
Converts the onData, on Done, and onError events into
Notification
objects that are passed into the downstream onData listener. [...]inherited -
max(
[Comparator< TResult> comparator ]) → AsObservableFuture<TResult> -
Converts a Stream into a Future that completes with the largest item emitted
by the Stream. [...]
inherited
-
mergeWith(
Iterable< Stream< streams) → Observable<TResult> >TResult> -
Combines the items emitted by multiple streams into a single stream of
items. The items are emitted in the order they are emitted by their
sources. [...]
inherited
-
min(
[Comparator< TResult> comparator ]) → AsObservableFuture<TResult> -
Converts a Stream into a Future that completes with the smallest item
emitted by the Stream. [...]
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed. [...]
inherited
-
ofType<
S> (TypeToken< S> typeToken) → Observable<S> -
Filters a sequence so that only events of a given type pass [...]
inherited
-
onErrorResume(
Stream< TResult> recoveryFn(dynamic error)) → Observable<TResult> -
Intercepts error events and switches to a recovery stream created by the
provided
recoveryFn
. [...]inherited -
onErrorResumeNext(
Stream< TResult> recoveryStream) → Observable<TResult> -
Intercepts error events and switches to the given recovery stream in
that case [...]
inherited
-
onErrorReturn(
TResult returnValue) → Observable< TResult> -
instructs an Observable to emit a particular item when it encounters an
error, and then terminate normally [...]
inherited
-
onErrorReturnWith(
TResult returnFn(dynamic error)) → Observable< TResult> -
instructs an Observable to emit a particular item created by the
returnFn
when it encounters an error, and then terminate normally. [...]inherited -
pairwise(
) → Observable< Iterable< TResult> > -
Emits the n-th and n-1th events as a pair.. [...]
inherited
-
pipe(
StreamConsumer< TResult> streamConsumer) → AsObservableFuture -
Pipes the events of this stream into
streamConsumer
. [...]inherited -
publish(
) → ConnectableObservable< TResult> -
Convert the current Observable into a
ConnectableObservable
that can be listened to multiple times. It will not begin emitting items from the original Observable until theconnect
method is invoked. [...]inherited -
publishReplay(
{int maxSize }) → ReplayConnectableObservable< TResult> -
Convert the current Observable into a
ReplayConnectableObservable
that can be listened to multiple times. It will not begin emitting items from the original Observable until theconnect
method is invoked. [...]inherited -
publishValue(
) → ValueConnectableObservable< TResult> -
Convert the current Observable into a
ValueConnectableObservable
that can be listened to multiple times. It will not begin emitting items from the original Observable until theconnect
method is invoked. [...]inherited -
publishValueSeeded(
TResult seedValue) → ValueConnectableObservable< TResult> -
Convert the current Observable into a
ValueConnectableObservable
that can be listened to multiple times, providing an initial seeded value. It will not begin emitting items from the original Observable until theconnect
method is invoked. [...]inherited -
reduce(
TResult combine(T previous, T element)) → AsObservableFuture< TResult> -
Combines a sequence of values by repeatedly applying
combine
. [...]inherited -
sample(
Stream sampleStream) → Observable< TResult> -
Emits the most recently emitted item (if any)
emitted by the source
Stream
since the previous emission from thesampleStream
. [...]inherited -
sampleTime(
Duration duration) → Observable< TResult> -
Emits the most recently emitted item (if any)
emitted by the source
Stream
since the previous emission within the recurring time span, defined byduration
[...]inherited -
scan<
S> (S accumulator(S accumulated, T value, int index), [ S seed ]) → Observable< S> -
Applies an accumulator function over an observable sequence and returns
each intermediate result. The optional seed value is used as the initial
accumulator value. [...]
inherited
-
Convert the current Observable into a new Observable that can be listened
to multiple times. It will automatically begin emitting items when first
listened to, and shut down when no listeners remain. [...]
inherited
-
Convert the current Observable into a new
ReplayObservable
that can be listened to multiple times. It will automatically begin emitting items when first listened to, and shut down when no listeners remain. [...]inherited -
Convert the current Observable into a new
ValueObservable
that can be listened to multiple times. It will automatically begin emitting items when first listened to, and shut down when no listeners remain. [...]inherited -
Convert the current Observable into a new
ValueObservable
that can be listened to multiple times, providing an initial value. It will automatically begin emitting items when first listened to, and shut down when no listeners remain. [...]inherited -
singleWhere(
bool test(T element), { TResult orElse() }) → AsObservableFuture< TResult> -
Finds the single element in this stream matching
test
. [...]inherited -
skip(
int count) → Observable< TResult> -
Skips the first count data events from this stream. [...]
inherited
-
skipUntil<
S> (Stream< S> otherStream) → Observable<TResult> -
Starts emitting items only after the given stream emits an item. [...]
inherited
-
skipWhile(
bool test(T element)) → Observable< TResult> -
Skip data events from this stream while they are matched by test. [...]
inherited
-
startWith(
TResult startValue) → Observable< TResult> -
Prepends a value to the source Observable. [...]
inherited
-
startWithMany(
List< TResult> startValues) → Observable<TResult> -
Prepends a sequence of values to the source Observable. [...]
inherited
-
switchIfEmpty(
Stream< TResult> fallbackStream) → Observable<TResult> -
When the original observable emits no items, this operator subscribes to
the given fallback stream and emits items from that observable instead. [...]
inherited
-
switchMap<
S> (Stream< S> mapper(T value)) → Observable<S> -
Converts each emitted item into a new Stream using the given mapper
function. The newly created Stream will be be listened to and begin
emitting items, and any previously created Stream will stop emitting. [...]
inherited
-
take(
int count) → Observable< TResult> -
Provides at most the first
n
values of this stream. Forwards the first n data events of this stream, and all error events, to the returned stream, and ends with a done event. [...]inherited -
takeUntil<
S> (Stream< S> otherStream) → Observable<TResult> -
Returns the values from the source observable sequence until the other
observable sequence produces a value. [...]
inherited
-
takeWhile(
bool test(T element)) → Observable< TResult> -
Forwards data events while test is successful. [...]
inherited
-
throttle(
Stream window(T event), { bool trailing: false }) → Observable< TResult> -
Emits only the first item emitted by the source
Stream
whilewindow
is open. [...]inherited -
throttleTime(
Duration duration, { bool trailing: false }) → Observable< TResult> -
Emits only the first item emitted by the source
Stream
within a time span ofduration
. [...]inherited -
timeInterval(
) → Observable< TimeInterval< TResult> > -
Records the time interval between consecutive values in an observable
sequence. [...]
inherited
-
timeout(
Duration timeLimit, { void onTimeout(EventSink< T> sink) }) → Observable<TResult> -
The Timeout operator allows you to abort an Observable with an onError
termination if that Observable fails to emit any items during a specified
duration. You may optionally provide a callback function to execute on
timeout.
inherited
-
timestamp(
) → Observable< Timestamped< TResult> > -
Wraps each item emitted by the source Observable in a
Timestamped
object that includes the emitted item and the time when the item was emitted. [...]inherited -
toList(
) → AsObservableFuture< List< TResult> > -
Collects all elements of this stream in a
List
. [...]inherited -
toSet(
) → AsObservableFuture< Set< TResult> > -
Collects the data of this stream in a
Set
. [...]inherited -
toString(
) → String -
Returns a string representation of this object.
inherited
-
transform<
S> (StreamTransformer< TResult, S> streamTransformer) → Observable<S> -
Applies
streamTransformer
to this stream. [...]inherited -
where(
bool test(T event)) → Observable< TResult> -
Filters the elements of an observable sequence based on the test.
inherited
-
window(
Stream window) → Observable< Stream< TResult> > -
Creates an Observable where each item is a
Stream
containing the items from the source sequence. [...]inherited -
windowCount(
int count, [ int startBufferEvery = 0 ]) → Observable< Stream< TResult> > -
Buffers a number of values from the source Observable by
count
then emits the buffer as aStream
and clears it, and starts a new buffer eachstartBufferEvery
values. IfstartBufferEvery
is not provided, then new buffers are started immediately at the start of the source and when each buffer closes and is emitted. [...]inherited -
windowTest(
bool onTestHandler(T event)) → Observable< Stream< TResult> > -
Creates an Observable where each item is a
Stream
containing the items from the source sequence, batched whenever test passes. [...]inherited -
windowTime(
Duration duration) → Observable< Stream< TResult> > -
Creates an Observable where each item is a
Stream
containing the items from the source sequence, sampled on a time frame withduration
. [...]inherited -
withLatestFrom<
S, R> (Stream< S> latestFromStream, R fn(T t, S s)) → Observable<R> -
Creates an Observable that emits when the source stream emits, combining
the latest values from the two streams using the provided function. [...]
inherited
-
zipWith<
S, R> (Stream< S> other, R zipper(T t, S s)) → Observable<R> -
Returns an Observable that combines the current stream together with
another stream using a given zipper function. [...]
inherited
Operators
-
operator ==(
dynamic other) → bool -
The equality operator. [...]
inherited
Static Methods
-
createAsync<
TParam, TResult> (AsyncFunc1< TParam, TResult> func, { Observable<bool> canExecute, bool emitInitialCommandResult: false, bool emitLastResult: false, bool emitsLastValueToNewSubscriptions: false, TResult initialLastResult }) → 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 isExecuting will issue abool
value on each state change. Even if you subscribe to a newly created command it will issuefalse
For theObservable<CommandResult>
that RxCommand publishes in results this normally doesn't make sense if you want to get an initial Result withdata==null, error==null, isExceuting==false
passemitInitialCommandResult=true
.emitLastResult
will include the value of the last successful execution in all CommandResult events unless there is no new result. By default the results Observable and the RxCommand itself behave like a PublishSubject. If you want that it acts like a BehaviourSubject, meaning every new listener gets the last received value, you can setemitsLastValueToNewSubscriptions = true
.initialLastResult
sets the value of the lastResult property before the first item was received. This is helpful if you use lastResult asinitialData
of aStreamBuilder
-
createAsyncNoParam<
TResult> (AsyncFunc< TResult> func, { Observable<bool> canExecute, bool emitInitialCommandResult: false, bool emitLastResult: false, bool emitsLastValueToNewSubscriptions: false, TResult initialLastResult }) → RxCommand<void, 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 isExecuting will issue abool
value on each state change. Even if you subscribe to a newly created command it will issuefalse
for theObservable<CommandResult>
that RxCommand publishes in results this normally doesn't make sense if you want to get an initial Result withdata==null, error==null, isExceuting==false
passemitInitialCommandResult=true
.emitLastResult
will include the value of the last successful execution in all CommandResult events unless there is no new result. By default the results Observable and the RxCommand itself behave like a PublishSubject. If you want that it acts like a BehaviourSubject, meaning every new listener gets the last received value, you can setemitsLastValueToNewSubscriptions = true
.initialLastResult
sets the value of the lastResult property before the first item was received. This is helpful if you use lastResult asinitialData
of aStreamBuilder
-
createAsyncNoParamNoResult(
AsyncAction action, { Observable< bool> canExecute, bool emitInitialCommandResult: false, bool emitsLastValueToNewSubscriptions: false }) → RxCommand<void, void> -
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 isExecuting will issue abool
value on each state change. Even if you subscribe to a newly created command it will issuefalse
For theObservable<CommandResult>
that RxCommand implement this normally doesn't make sense if you want to get an initial Result withdata==null, error==null, isExceuting==false
passemitInitialCommandResult=true
. By default the results Observable and the RxCommand itself behave like a PublishSubject. If you want that it acts like a BehaviourSubject, meaning every new listener gets the last received value, you can setemitsLastValueToNewSubscriptions = true
. -
createAsyncNoResult<
TParam> (AsyncAction1< TParam> action, { Observable<bool> canExecute, bool emitInitialCommandResult: false, bool emitsLastValueToNewSubscriptions: false }) → RxCommand<TParam, void> -
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 isExecuting will issue abool
value on each state change. Even if you subscribe to a newly created command it will issuefalse
For theObservable<CommandResult>
that RxCommand implement this normally doesn't make sense if you want to get an initial Result withdata==null, error==null, isExceuting==false
passemitInitialCommandResult=true
. By default the results Observable and the RxCommand itself behave like a PublishSubject. If you want that it acts like a BehaviourSubject, meaning every new listener gets the last received value, you can setemitsLastValueToNewSubscriptions = true
. -
createFromStream<
TParam, TResult> (StreamProvider< TParam, TResult> provider, { Observable<bool> canExecute, bool emitInitialCommandResult: false, bool emitLastResult: false, bool emitsLastValueToNewSubscriptions: false, TResult initialLastResult }) → RxCommand<TParam, TResult> -
Creates a RxCommand from an "one time" observable. This is handy if used together with a streame generator function.
provider
: provider function that returns a new Observable that will be subscribed on the call of executecanExecute
: 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 isExecuting will issue abool
value on each state change. Even if you subscribe to a newly created command it will issuefalse
For theObservable<CommandResult>
that RxCommand publishes in results this normally doesn't make sense if you want to get an initial Result withdata==null, error==null, isExceuting==false
passemitInitialCommandResult=true
.emitLastResult
will include the value of the last successful execution in all CommandResult events unless there is no new result. By default the results Observable and the RxCommand itself behave like a PublishSubject. If you want that it acts like a BehaviourSubject, meaning every new listener gets the last received value, you can setemitsLastValueToNewSubscriptions = true
.initialLastResult
sets the value of the lastResult property before the first item was received. This is helpful if you use lastResult asinitialData
of aStreamBuilder
-
createSync<
TParam, TResult> (Func1< TParam, TResult> func, { Observable<bool> canExecute, bool emitInitialCommandResult: false, bool emitLastResult: false, bool emitsLastValueToNewSubscriptions: false, TResult initialLastResult }) → 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 isExecuting will issue abool
value on each state change. Even if you subscribe to a newly created command it will issuefalse
For theObservable<CommandResult>
that RxCommand implement this normally doesn't make sense if you want to get an initial Result withdata==null, error==null, isExceuting==false
passemitInitialCommandResult=true
.emitLastResult
will include the value of the last successful execution in all CommandResult events unless there is no new result. By default the results Observable and the RxCommand itself behave like a PublishSubject. If you want that it acts like a BehaviourSubject, meaning every new listener gets the last received value, you can setemitsLastValueToNewSubscriptions = true
.initialLastResult
sets the value of the lastResult property before the first item was received. This is helpful if you use lastResult asinitialData
of aStreamBuilder
-
createSyncNoParam<
TResult> (Func< TResult> func, { Observable<bool> canExecute, bool emitInitialCommandResult: false, bool emitLastResult: false, bool emitsLastValueToNewSubscriptions: false, TResult initialLastResult }) → RxCommand<void, 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 isExecuting will issue abool
value on each state change. Even if you subscribe to a newly created command it will issuefalse
emitLastResult
will include the value of the last successful execution in all CommandResult events unless there is no new result. For theObservable<CommandResult>
that RxCommand publishes in results this normally doesn't make sense if you want to get an initial Result withdata==null, error==null, isExceuting==false
passemitInitialCommandResult=true
. By default the results Observable and the RxCommand itself behave like a PublishSubject. If you want that it acts like a BehaviourSubject, meaning every new listener gets the last received value, you can setemitsLastValueToNewSubscriptions = true
.initialLastResult
sets the value of the lastResult property before the first item was received. This is helpful if you use lastResult asinitialData
of aStreamBuilder
-
createSyncNoParamNoResult(
Action action, { Observable< bool> canExecute, bool emitInitialCommandResult: false, bool emitsLastValueToNewSubscriptions: false }) → RxCommand<void, void> -
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 isExecuting will issue abool
value on each state change. Even if you subscribe to a newly created command it will issuefalse
For theObservable<CommandResult>
that RxCommand publishes in results this normally doesn't make sense if you want to get an initial Result withdata==null, error==null, isExceuting==false
passemitInitialCommandResult=true
. By default the results Observable and the RxCommand itself behave like a PublishSubject. If you want that it acts like a BehaviourSubject, meaning every new listener gets the last received value, you can setemitsLastValueToNewSubscriptions = true
. -
createSyncNoResult<
TParam> (Action1< TParam> action, { Observable<bool> canExecute, bool emitInitialCommandResult: false, bool emitsLastValueToNewSubscriptions: false }) → RxCommand<TParam, void> -
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 isExecuting will issue abool
value on each state change. Even if you subscribe to a newly created command it will issuefalse
For theObservable<CommandResult>
that RxCommand publishes in results this normally doesn't make sense if you want to get an initial Result withdata==null, error==null, isExceuting==false
passemitInitialCommandResult=true
. By default the results Observable and the RxCommand itself behave like a PublishSubject. If you want that it acts like a BehaviourSubject, meaning every new listener gets the last received value, you can setemitsLastValueToNewSubscriptions = true
.