Exemplo n.º 1
0
 /// <summary>
 /// Executes the first command and then when it completes executes the second command.  TInput is passed to the
 /// first command and the output of that command is fed in as the argument to the seond command. The returned command
 /// expects TInput and returns TSecondOutput when executed.
 /// </summary>
 /// <param name="first">The command to execute first</param>
 /// <param name="second">The command to execute second</param>
 /// <returns>The new command that executes both commands in turn.</returns>
 public static IRxFunction <TInput, TSecondOutput> Combine <TInput, TFirstOutput, TSecondOutput>(this IRxFunction <TInput, TFirstOutput> first, IRxFunction <TFirstOutput, TSecondOutput> second)
 {
     return(RxFunction.CreateAsync <TInput, TSecondOutput>(async x =>
     {
         var firstResult = await first.InvokeAsync(x);
         return await second.InvokeAsync(firstResult);
     }));
 }
Exemplo n.º 2
0
 /// <summary>
 /// Executes the first command and then when it completes executes the second command.  Both commands
 /// expect TInput as a parameter.  The second command returns TOutput. The returned command expects
 /// TInput and returns TOutput when executed.
 /// </summary>
 /// <param name="first">The command to execute first</param>
 /// <param name="second">The command to execute second</param>
 /// <returns>The new command that executes both commands in turn.</returns>
 public static IRxFunction <TInput, TOutput> Combine <TInput, TOutput>(this IRxCommand <TInput> first, IRxFunction <TInput, TOutput> second)
 {
     return(RxFunction.CreateAsync <TInput, TOutput>(async x =>
     {
         await first.InvokeAsync(x);
         return await second.InvokeAsync(x);
     }));
 }
Exemplo n.º 3
0
 /// <summary>
 /// Executes the first command and then when it completes executes the second command.  The first command
 /// returns TOutput.  The returned command also returns TOutput.
 /// </summary>
 /// <param name="first">The command to execute first</param>
 /// <param name="second">The command to execute second</param>
 /// <returns>The new command that executes both commands in turn.</returns>
 public static IRxFunction <TOutput> Combine <TOutput>(this IRxFunction <TOutput> first, IRxCommand second)
 {
     return(RxFunction.CreateAsync(async() =>
     {
         var result = await first.InvokeAsync();
         await second.InvokeAsync();
         return result;
     }));
 }
Exemplo n.º 4
0
 /// <summary>
 /// Creates a command that consumes input and produces output.
 /// </summary>
 /// <param name="action">The action to execute when invoking the command.</param>
 /// <param name="canExecute">An observable that dictates whether or not the command may execute. If not
 /// specified, an observable is created that produces true.</param>
 /// <param name="defaultValue">A factory function to provide the return value for when the method fails to execute.</param>
 /// <param name="allowSimultaneousExecution">If true, multiple execution of this command may be performed.  If false,
 /// then subsequent calls to ExecuteAsync return the defaultValue until the execution of the initial invocation completes.</param>
 public static IRxFunction <TInput, TOutput> CreateAsync <TInput, TOutput>(Func <TInput, Task <TOutput> > action, IObservable <bool> canExecute = null, Func <TOutput> defaultValue = null, bool allowSimultaneousExecution = false)
 {
     return(RxFunction <TInput> .CreateAsync(action, canExecute, defaultValue, allowSimultaneousExecution));
 }
Exemplo n.º 5
0
 /// <summary>
 /// Converts an unparameterized command into a command parameterized by Unit.  This can be useful with methods such
 /// as Combine which expect particular types of commands that may not fit the command you have in order to
 /// get the behavor you otherwise expect.
 /// </summary>
 public static IRxFunction <Unit, TOutput> AsParameterized <TOutput>(this IRxFunction <TOutput> command)
 {
     return(RxFunction.CreateAsync <Unit, TOutput>(_ => command.InvokeAsync()));
 }