Skip to content

Commit

Permalink
ObserveON more(not yet completed)
Browse files Browse the repository at this point in the history
  • Loading branch information
neuecc committed Dec 25, 2023
1 parent 4891702 commit 8b767b3
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions src/R3/Operators/_Operators.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,38 @@ public static partial class ObservableExtensions

// return tasks:
// All, Any, Contains, SequenceEqual, IsEmpty, MaxBy, MinBy, ToDictionary, ToLookup,



// ObserveOn extension method
public static Observable<T> ObserveOn<T>(this Observable<T> source, SynchronizationContext? synchronizationContext)
{
if (synchronizationContext == null)
{
return ObserveOn<T>(source, TimeProvider.System); // use ThreadPool instead
}

return new ObserveOnSynchronizationContext<T>(source, synchronizationContext);
}

public static Observable<T> ObserveOn<T>(this Observable<T> source, TimeProvider timeProvider)
{
if (timeProvider == TimeProvider.System)
{
return new ObserveOnThreadPool<T>(source);
}

return new ObserveOnTimeProvider<T>(source, timeProvider);
}

public static Observable<T> ObserveOn<T>(this Observable<T> source, FrameProvider frameProvider)
{
return new ObserveOnFrameProvider<T>(source, frameProvider);
}
}



// ObserveOnFrameProvider
// ObserveOnTimeProvider

internal sealed class ObserveOnSynchronizationContext<T>(Observable<T> source, SynchronizationContext synchronizationContext) : Observable<T>
{
Expand Down

0 comments on commit 8b767b3

Please sign in to comment.