Skip to content
This repository was archived by the owner on Feb 16, 2024. It is now read-only.

Add ToAsync functions #218

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add ToAsync functions #218

wants to merge 1 commit into from

Conversation

Bezarius
Copy link
Contributor

  • Func<T, IObservable> ToAsync<T, TResult>(Func<T, TResult> function)
  • Func<T, IObservable> ToAsync<T, TResult>(Func<T, TResult> function, IScheduler scheduler)
  • Func<T1, T2, IObservable> ToAsync<T1, T2, TResult>(Func<T1, T2, TResult> function)
  • Func<T1, T2, IObservable> ToAsync<T1, T2, TResult>(Func<T1, T2, TResult> function, IScheduler scheduler)
  • Func<T1, T2, T3, IObservable> ToAsync<T1, T2, T3, TResult>(Func<T1, T2, T3, TResult> function)
  • Func<T1, T2, T3, IObservable> ToAsync<T1, T2, T3, TResult>(Func<T1, T2, T3, TResult> function, IScheduler scheduler)
  • Func<T1, T2, T3, T4, IObservable> ToAsync<T1, T2, T3, T4, TResult>(Func<T1, T2, T3, T4, TResult> function)
  • Func<T1, T2, T3, T4, IObservable> ToAsync<T1, T2, T3, T4, TResult>(Func<T1, T2, T3, T4, TResult> function, IScheduler scheduler)
  • Func<T1, T2, IObservable> ToAsync<T1, T2>(Action<T1, T2> action)
  • Func<T1, T2, IObservable> ToAsync<T1, T2>(Action<T1, T2> action, IScheduler scheduler)
  • Func<T1, T2, T3, IObservable> ToAsync<T1, T2, T3>(Action<T1, T2, T3> action)
  • Func<T1, T2, T3, IObservable> ToAsync<T1, T2, T3>(Action<T1, T2, T3> action, IScheduler scheduler)
  • Func<T1, T2, T3, T4, IObservable> ToAsync<T1, T2, T3, T4>(Action<T1, T2, T3, T4> action)
  • Func<T1, T2, T3, T4, IObservable> ToAsync<T1, T2, T3, T4>(Action<T1, T2, T3, T4> action, IScheduler scheduler)

Run a method asynchronously on demand

Execute a long-running method asynchronously. The method does not start running until there is a subscriber. The method is started every time the observable is created and subscribed, so there could be more than one running at once.

// Synchronous operation
public DataType DoLongRunningOperation(string param)
{
    ...
}

public IObservable<DataType> LongRunningOperationAsync(string param)
{
    return Observable.Create<DataType>(
        o => Observable.ToAsync<string,DataType>(DoLongRunningOperation)(param).Subscribe(o)
    );
}

 - Func<T, IObservable<TResult>> ToAsync<T, TResult>(Func<T, TResult> function)
 - Func<T, IObservable<TResult>> ToAsync<T, TResult>(Func<T, TResult> function, IScheduler scheduler)
 - Func<T1, T2, IObservable<TResult>> ToAsync<T1, T2, TResult>(Func<T1, T2, TResult> function)
 - Func<T1, T2, IObservable<TResult>> ToAsync<T1, T2, TResult>(Func<T1, T2, TResult> function, IScheduler scheduler)
 - Func<T1, T2, T3, IObservable<TResult>> ToAsync<T1, T2, T3, TResult>(Func<T1, T2, T3, TResult> function)
 - Func<T1, T2, T3, IObservable<TResult>> ToAsync<T1, T2, T3, TResult>(Func<T1, T2, T3, TResult> function, IScheduler scheduler)
 - Func<T1, T2, T3, T4, IObservable<TResult>> ToAsync<T1, T2, T3, T4, TResult>(Func<T1, T2, T3, T4, TResult> function)
 - Func<T1, T2, T3, T4, IObservable<TResult>> ToAsync<T1, T2, T3, T4, TResult>(Func<T1, T2, T3, T4, TResult> function, IScheduler scheduler)
 - Func<T1, T2, IObservable<Unit>> ToAsync<T1, T2>(Action<T1, T2> action)
 - Func<T1, T2, IObservable<Unit>> ToAsync<T1, T2>(Action<T1, T2> action, IScheduler scheduler)
 - Func<T1, T2, T3, IObservable<Unit>> ToAsync<T1, T2, T3>(Action<T1, T2, T3> action)
 - Func<T1, T2, T3, IObservable<Unit>> ToAsync<T1, T2, T3>(Action<T1, T2, T3> action, IScheduler scheduler)
 - Func<T1, T2, T3, T4, IObservable<Unit>> ToAsync<T1, T2, T3, T4>(Action<T1, T2, T3, T4> action)
 - Func<T1, T2, T3, T4, IObservable<Unit>> ToAsync<T1, T2, T3, T4>(Action<T1, T2, T3, T4> action, IScheduler scheduler)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant