createFromStream<TParam, TResult> static method
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 Observable that will be subscribed on the call of execute
restriction
: observable that can be used to enable/disable the command based on some other state change
if omitted the command can be executed always except it's already executing
isExecuting will issue a bool
value on each state change. Even if you
subscribe to a newly created command it will issue false
For the Observable<CommandResult>
that RxCommand publishes in results this normally doesn't make sense
if you want to get an initial Result with data==null, error==null, isExecuting==false
pass
emitInitialCommandResult=true
.
emitLastResult
will include the value of the last successful execution in all CommandResult events unless there is no 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 listener gets the last received value, you can set emitsLastValueToNewSubscriptions = true
.
initialLastResult
sets the value of the lastResult property before the first item was received. This is helpful if you use
lastResult as initialData
of a StreamBuilder
debugName
optional identifier that is included when you register a globalExceptionHandler
or a loggingHandler
Implementation
static RxCommand<TParam, TResult> createFromStream<TParam, TResult>(
StreamProvider<TParam, TResult> provider,
{Stream<bool>? restriction,
bool emitInitialCommandResult = false,
bool emitLastResult = false,
bool emitsLastValueToNewSubscriptions = false,
TResult? initialLastResult,
String? debugName}) {
return RxCommandStream<TParam, TResult>(
provider,
restriction,
emitInitialCommandResult,
emitLastResult,
emitsLastValueToNewSubscriptions,
initialLastResult,
false,
debugName,
false);
}