Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/ReactiveUI.Blazor/Registrations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void Register(Action<Func<object>, Type> registerFunction)
PlatformEnlightenmentProvider.Current.EnableWasm();
}

RxApp.TaskpoolScheduler = TaskPoolScheduler.Default;
RxApp.MainThreadScheduler = CurrentThreadScheduler.Instance;
RxSchedulers.TaskpoolScheduler = TaskPoolScheduler.Default;
RxSchedulers.MainThreadScheduler = CurrentThreadScheduler.Instance;
}
}
2 changes: 1 addition & 1 deletion src/ReactiveUI.Blend/FollowObservableStateBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ protected static void OnStateObservableChanged(DependencyObject? sender, Depende
#pragma warning disable CA2208 // Instantiate argument exceptions correctly
var newValue = (IObservable<string>)e.NewValue ?? throw new ArgumentNullException(nameof(e.NewValue));
#pragma warning restore CA2208 // Instantiate argument exceptions correctly
item._watcher = newValue.ObserveOn(RxApp.MainThreadScheduler).Subscribe(
item._watcher = newValue.ObserveOn(RxSchedulers.MainThreadScheduler).Subscribe(
x =>
{
var target = item.TargetObject ?? item.AssociatedObject;
Expand Down
2 changes: 1 addition & 1 deletion src/ReactiveUI.Blend/Platforms/net4/ObservableTrigger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ protected static void OnObservableChanged(DependencyObject sender, DependencyPro
triggerItem._watcher = null;
}

triggerItem._watcher = ((IObservable<object>)e.NewValue).ObserveOn(RxApp.MainThreadScheduler).Subscribe(
triggerItem._watcher = ((IObservable<object>)e.NewValue).ObserveOn(RxSchedulers.MainThreadScheduler).Subscribe(
triggerItem.InvokeActions,
_ =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ private static void OnObservableChanged(DependencyObject sender, DependencyPrope
{
var @this = (ObservableTriggerBehavior)sender;

@this._watcher.Disposable = ((IObservable<object>)e.NewValue).ObserveOn(RxApp.MainThreadScheduler).Subscribe(
@this._watcher.Disposable = ((IObservable<object>)e.NewValue).ObserveOn(RxSchedulers.MainThreadScheduler).Subscribe(
x => Interaction.ExecuteActions(@this._resolvedSource, @this.Actions, x),
ex =>
{
Expand Down
4 changes: 2 additions & 2 deletions src/ReactiveUI.Builder.WpfApp/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ protected override void OnStartup(StartupEventArgs e)
// Network service used to broadcast/receive messages across instances
r.RegisterLazySingleton(static () => new Services.ChatNetworkService());
})
.Build();
.BuildApp();

// Setup Suspension
RxApp.SuspensionHost.CreateNewAppState = static () => new ChatState();
Expand All @@ -74,7 +74,7 @@ protected override void OnStartup(StartupEventArgs e)
// Load persisted state asynchronously and update UI when ready
_ = _driver
.LoadState()
.ObserveOn(RxApp.MainThreadScheduler)
.ObserveOn(RxSchedulers.MainThreadScheduler)
.Subscribe(
static stateObj =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public ChatRoomViewModel(IScreen hostScreen, ChatRoom room, string user)
MessageBus.Current.Listen<ChatNetworkMessage>(contract: room.Name)
.Where(msg => msg.InstanceId != Services.AppInstance.Id)
.Throttle(TimeSpan.FromMilliseconds(33))
.ObserveOn(RxApp.MainThreadScheduler)
.ObserveOn(RxSchedulers.MainThreadScheduler)
.Subscribe(msg =>
{
_room.Messages.Add(new ChatMessage { Sender = msg.Sender, Text = msg.Text, Timestamp = msg.Timestamp });
Expand Down
4 changes: 2 additions & 2 deletions src/ReactiveUI.Builder.WpfApp/ViewModels/LobbyViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ public LobbyViewModel(IScreen hostScreen)
this.WhenAnyObservable(x => x.RoomsChanged)
.StartWith(Unit.Default)
.Select(_ => (IReadOnlyList<ChatRoom>)[.. GetState().Rooms])
.ObserveOn(RxApp.MainThreadScheduler)
.ObserveOn(RxSchedulers.MainThreadScheduler)
.ToProperty(this, nameof(Rooms), out _rooms);

// Request a snapshot from peers shortly after activation
RxApp.MainThreadScheduler.Schedule(Unit.Default, TimeSpan.FromMilliseconds(500), (s, __) =>
RxSchedulers.MainThreadScheduler.Schedule(Unit.Default, TimeSpan.FromMilliseconds(500), (s, __) =>
{
var req = new Services.RoomEventMessage(Services.RoomEventKind.SyncRequest, string.Empty) { InstanceId = Services.AppInstance.Id };
Trace.WriteLine("[Lobby] Broadcasting SyncRequest");
Expand Down
2 changes: 1 addition & 1 deletion src/ReactiveUI.Maui/Common/ViewModelViewHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public ViewModelViewHost()
this.WhenActivated(d =>
{
d(contractChanged
.ObserveOn(RxApp.MainThreadScheduler)
.ObserveOn(RxSchedulers.MainThreadScheduler)
.Subscribe(x => _viewContract = x ?? string.Empty));

d(vmAndContract.DistinctUntilChanged().Subscribe(x => ResolveViewForViewModel(x.ViewModel, x.Contract)));
Expand Down
4 changes: 2 additions & 2 deletions src/ReactiveUI.Maui/Registrations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ public void Register(Action<Func<object>, Type> registerFunction)

if (!ModeDetector.InUnitTestRunner())
{
RxApp.MainThreadScheduler = new WaitForDispatcherScheduler(static () => DispatcherQueueScheduler.Current);
RxApp.TaskpoolScheduler = TaskPoolScheduler.Default;
RxSchedulers.MainThreadScheduler = new WaitForDispatcherScheduler(static () => DispatcherQueueScheduler.Current);
RxSchedulers.TaskpoolScheduler = TaskPoolScheduler.Default;
}

RxApp.SuppressViewCommandBindingMessage = true;
Expand Down
4 changes: 2 additions & 2 deletions src/ReactiveUI.Maui/RoutedViewHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public RoutedViewHost()
Router?
.Navigate
.Where(_ => StacksAreDifferent())
.ObserveOn(RxApp.MainThreadScheduler)
.ObserveOn(RxSchedulers.MainThreadScheduler)
.SelectMany(_ => PagesForViewModel(Router.GetCurrentViewModel()))
.SelectMany(async page =>
{
Expand Down Expand Up @@ -245,7 +245,7 @@ protected virtual Page PageForViewModel(IRoutableViewModel vm)

if (SetTitleOnNavigate)
{
RxApp.MainThreadScheduler.Schedule(() => pg.Title = vm.UrlPathSegment);
RxSchedulers.MainThreadScheduler.Schedule(() => pg.Title = vm.UrlPathSegment);
}

return pg;
Expand Down
2 changes: 1 addition & 1 deletion src/ReactiveUI.Winforms/Registrations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void Register(Action<Func<object>, Type> registerFunction)
if (!ModeDetector.InUnitTestRunner())
{
WindowsFormsSynchronizationContext.AutoInstall = true;
RxApp.MainThreadScheduler = new WaitForDispatcherScheduler(static () => new SynchronizationContextScheduler(new WindowsFormsSynchronizationContext()));
RxSchedulers.MainThreadScheduler = new WaitForDispatcherScheduler(static () => new SynchronizationContextScheduler(new WindowsFormsSynchronizationContext()));
}
}
}
2 changes: 1 addition & 1 deletion src/ReactiveUI.Wpf/Common/ViewModelViewHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public ViewModelViewHost()
this.WhenActivated(d =>
{
d(contractChanged
.ObserveOn(RxApp.MainThreadScheduler)
.ObserveOn(RxSchedulers.MainThreadScheduler)
.Subscribe(x => _viewContract = x ?? string.Empty));

d(vmAndContract.DistinctUntilChanged().Subscribe(x => ResolveViewForViewModel(x.ViewModel, x.Contract)));
Expand Down
4 changes: 2 additions & 2 deletions src/ReactiveUI.Wpf/Registrations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ public void Register(Action<Func<object>, Type> registerFunction)
if (!ModeDetector.InUnitTestRunner())
{
// NB: On .NET Core, trying to touch DispatcherScheduler blows up :cry:
RxApp.MainThreadScheduler = new WaitForDispatcherScheduler(static () => DispatcherScheduler.Current);
RxApp.TaskpoolScheduler = TaskPoolScheduler.Default;
RxSchedulers.MainThreadScheduler = new WaitForDispatcherScheduler(static () => DispatcherScheduler.Current);
RxSchedulers.TaskpoolScheduler = TaskPoolScheduler.Default;
}

RxApp.SuppressViewCommandBindingMessage = true;
Expand Down
80 changes: 0 additions & 80 deletions src/ReactiveUI.Wpf/Rx/Linq/DispatcherObservable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,43 +133,6 @@ public static IObservable<TSource> ObserveOn<TSource>(this IObservable<TSource>
return ObserveOn_(source, dispatcherObject.Dispatcher, priority);
}


/// <summary>
/// Wraps the source sequence in order to run its observer callbacks on the dispatcher associated with the current thread.
/// </summary>
/// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
/// <param name="source">Source sequence.</param>
/// <returns>The source sequence whose observations happen on the current thread's dispatcher.</returns>
/// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
[Obsolete("Use ObserveOn(RxApp.MainThreadScheduler)", false)]
public static IObservable<TSource> ObserveOnDispatcher<TSource>(this IObservable<TSource> source)
{
if (source == null)
{
throw new ArgumentNullException(nameof(source));
}

return ObserveOn_(source, DispatcherScheduler.Current.Dispatcher);
}

/// <summary>
/// Wraps the source sequence in order to run its observer callbacks on the dispatcher associated with the current thread.
/// </summary>
/// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
/// <param name="source">Source sequence.</param>
/// <param name="priority">Priority to schedule work items at.</param>
/// <returns>The source sequence whose observations happen on the current thread's dispatcher.</returns>
/// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
public static IObservable<TSource> ObserveOnDispatcher<TSource>(this IObservable<TSource> source, DispatcherPriority priority)
{
if (source == null)
{
throw new ArgumentNullException(nameof(source));
}

return ObserveOn_(source, DispatcherScheduler.Current.Dispatcher, priority);
}

private static IObservable<TSource> ObserveOn_<TSource>(IObservable<TSource> source, Dispatcher dispatcher, DispatcherPriority priority)
{
return Synchronization.ObserveOn(source, new DispatcherSynchronizationContext(dispatcher, priority));
Expand Down Expand Up @@ -323,49 +286,6 @@ public static IObservable<TSource> SubscribeOn<TSource>(this IObservable<TSource
return SubscribeOn_(source, dispatcherObject.Dispatcher, priority);
}

/// <summary>
/// Wraps the source sequence in order to run its subscription and unsubscription logic on the dispatcher associated with the current thread.
/// </summary>
/// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
/// <param name="source">Source sequence.</param>
/// <returns>The source sequence whose subscriptions and unsubscriptions happen on the current thread's dispatcher.</returns>
/// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
/// <remarks>
/// Only the side-effects of subscribing to the source sequence and disposing subscriptions to the source sequence are run on the dispatcher associated with the current thread.
/// In order to invoke observer callbacks on the dispatcher associated with the current thread, e.g. to render results in a control, use <see cref="DispatcherObservable.ObserveOnDispatcher{TSource}(IObservable{TSource})"/>.
/// </remarks>
public static IObservable<TSource> SubscribeOnDispatcher<TSource>(this IObservable<TSource> source)
{
if (source == null)
{
throw new ArgumentNullException(nameof(source));
}

return SubscribeOn_(source, DispatcherScheduler.Current.Dispatcher);
}

/// <summary>
/// Wraps the source sequence in order to run its subscription and unsubscription logic on the dispatcher associated with the current thread.
/// </summary>
/// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
/// <param name="source">Source sequence.</param>
/// <param name="priority">Priority to schedule work items at.</param>
/// <returns>The source sequence whose observations happen on the current thread's dispatcher.</returns>
/// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
/// <remarks>
/// Only the side-effects of subscribing to the source sequence and disposing subscriptions to the source sequence are run on the dispatcher associated with the current thread.
/// In order to invoke observer callbacks on the dispatcher associated with the current thread, e.g. to render results in a control, use <see cref="DispatcherObservable.ObserveOnDispatcher{TSource}(IObservable{TSource}, DispatcherPriority)"/>.
/// </remarks>
public static IObservable<TSource> SubscribeOnDispatcher<TSource>(this IObservable<TSource> source, DispatcherPriority priority)
{
if (source == null)
{
throw new ArgumentNullException(nameof(source));
}

return SubscribeOn_(source, DispatcherScheduler.Current.Dispatcher, priority);
}

private static IObservable<TSource> SubscribeOn_<TSource>(IObservable<TSource> source, Dispatcher dispatcher, DispatcherPriority priority)
{
return Synchronization.SubscribeOn(source, new DispatcherSynchronizationContext(dispatcher, priority));
Expand Down
2 changes: 1 addition & 1 deletion src/ReactiveUI.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 18
VisualStudioVersion = 18.0.11018.127 d18.0
VisualStudioVersion = 18.0.11018.127
MinimumVisualStudioVersion = 16.0.31613.86
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{BD9762CF-E104-481C-96A6-26E624B86283}"
ProjectSection(SolutionItems) = preProject
Expand Down
4 changes: 2 additions & 2 deletions src/ReactiveUI/Builder/ReactiveUIBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -926,12 +926,12 @@ private void ConfigureSchedulers() =>
{
if (MainThreadScheduler != null && _setRxAppMainScheduler)
{
RxApp.MainThreadScheduler = MainThreadScheduler;
RxSchedulers.MainThreadScheduler = MainThreadScheduler;
}

if (TaskpoolScheduler != null && _setRxAppTaskPoolScheduler)
{
RxApp.TaskpoolScheduler = TaskpoolScheduler;
RxSchedulers.TaskpoolScheduler = TaskpoolScheduler;
}
});
}
4 changes: 2 additions & 2 deletions src/ReactiveUI/Mixins/AutoPersistHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,14 @@ public static IDisposable AutoPersist<T, TDontCare>(this T @this, Func<T, IObser
var saveHint = @this.GetChangedObservable().Where(x => x.PropertyName is not null && persistableProperties.ContainsKey(x.PropertyName)).Select(_ => Unit.Default).Merge(manualSaveSignal.Select(_ => Unit.Default));

var autoSaver = saveHint
.Throttle(interval.Value, RxApp.TaskpoolScheduler)
.Throttle(interval.Value, RxSchedulers.TaskpoolScheduler)
.SelectMany(_ => doPersist(@this))
.Publish();

// NB: This rigamarole is to prevent the initialization of a class
// from triggering a save
var ret = new SingleAssignmentDisposable();
RxApp.MainThreadScheduler.Schedule(() =>
RxSchedulers.MainThreadScheduler.Schedule(() =>
{
if (ret.IsDisposed)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class POCOObservableForProperty : ICreatesObservableForProperty
_hasWarned[(type, propertyName)] = true;
}

return Observable.Return(new ObservedChange<object, object?>(sender, expression, default), RxApp.MainThreadScheduler ?? CurrentThreadScheduler.Instance)
return Observable.Return(new ObservedChange<object, object?>(sender, expression, default), RxSchedulers.MainThreadScheduler ?? CurrentThreadScheduler.Instance)
.Concat(Observable<IObservedChange<object, object?>>.Never);
}
}
4 changes: 2 additions & 2 deletions src/ReactiveUI/Platforms/android/PlatformRegistrations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ public void Register(Action<Func<object>, Type> registerFunction) // TODO: Creat

if (!ModeDetector.InUnitTestRunner())
{
RxApp.TaskpoolScheduler = TaskPoolScheduler.Default;
RxApp.MainThreadScheduler = HandlerScheduler.MainThreadScheduler;
RxSchedulers.TaskpoolScheduler = TaskPoolScheduler.Default;
RxSchedulers.MainThreadScheduler = HandlerScheduler.MainThreadScheduler;
}

registerFunction(static () => new BundleSuspensionDriver(), typeof(ISuspensionDriver));
Expand Down
2 changes: 1 addition & 1 deletion src/ReactiveUI/Platforms/apple-common/ReactiveControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public override void ViewWillMoveToSuperview(NSView? newsuper)

/// <inheritdoc/>
void ICanForceManualActivation.Activate(bool activate) =>
RxApp.MainThreadScheduler.Schedule(() =>
RxSchedulers.MainThreadScheduler.Schedule(() =>
(activate ? _activated : _deactivated).OnNext(Unit.Default));

/// <inheritdoc/>
Expand Down
2 changes: 1 addition & 1 deletion src/ReactiveUI/Platforms/apple-common/ReactiveImageView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public override void ViewWillMoveToSuperview(NSView? newsuper)

/// <inheritdoc/>
void ICanForceManualActivation.Activate(bool activate) =>
RxApp.MainThreadScheduler.Schedule(() =>
RxSchedulers.MainThreadScheduler.Schedule(() =>
(activate ? _activated : _deactivated).OnNext(Unit.Default));

/// <inheritdoc/>
Expand Down
2 changes: 1 addition & 1 deletion src/ReactiveUI/Platforms/apple-common/ReactiveView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public override void ViewWillMoveToSuperview(NSView? newsuper)

/// <inheritdoc/>
void ICanForceManualActivation.Activate(bool activate) =>
RxApp.MainThreadScheduler.Schedule(() =>
RxSchedulers.MainThreadScheduler.Schedule(() =>
(activate ? _activated : _deactivated).OnNext(Unit.Default));

/// <inheritdoc/>
Expand Down
6 changes: 3 additions & 3 deletions src/ReactiveUI/Platforms/apple-common/ViewModelViewHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public ViewModelViewHost()
_currentView = new SerialDisposable();
_viewContract = this
.WhenAnyObservable(static x => x.ViewContractObservable)
.ToProperty(this, static x => x.ViewContract, initialValue: null, scheduler: RxApp.MainThreadScheduler);
.ToProperty(this, static x => x.ViewContract, initialValue: null, scheduler: RxSchedulers.MainThreadScheduler);

Initialize();
}
Expand Down Expand Up @@ -181,7 +181,7 @@ private void Initialize()
.Select(x => x.DefaultContent);

viewChange
.ObserveOn(RxApp.MainThreadScheduler)
.ObserveOn(RxSchedulers.MainThreadScheduler)
.Subscribe(
x =>
{
Expand Down Expand Up @@ -215,7 +215,7 @@ private void Initialize()
});

defaultViewChange
.ObserveOn(RxApp.MainThreadScheduler)
.ObserveOn(RxSchedulers.MainThreadScheduler)
.Subscribe(x => Adopt(this, x));
}
}
2 changes: 1 addition & 1 deletion src/ReactiveUI/Platforms/mac/AutoSuspendHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public AutoSuspendHelper(NSApplicationDelegate appDelegate)
/// <returns>The termination reply from the application.</returns>
public NSApplicationTerminateReply ApplicationShouldTerminate(NSApplication sender)
{
RxApp.MainThreadScheduler.Schedule(() =>
RxSchedulers.MainThreadScheduler.Schedule(() =>
_shouldPersistState.OnNext(Disposable.Create(() =>
sender.ReplyToApplicationShouldTerminate(true))));

Expand Down
4 changes: 2 additions & 2 deletions src/ReactiveUI/Platforms/mac/PlatformRegistrations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public void Register(Action<Func<object>, Type> registerFunction)

if (!ModeDetector.InUnitTestRunner())
{
RxApp.TaskpoolScheduler = TaskPoolScheduler.Default;
RxApp.MainThreadScheduler = new WaitForDispatcherScheduler(static () => new NSRunloopScheduler());
RxSchedulers.TaskpoolScheduler = TaskPoolScheduler.Default;
RxSchedulers.MainThreadScheduler = new WaitForDispatcherScheduler(static () => new NSRunloopScheduler());
}

registerFunction(static () => new AppSupportJsonSuspensionDriver(), typeof(ISuspensionDriver));
Expand Down
4 changes: 2 additions & 2 deletions src/ReactiveUI/Platforms/net/PlatformRegistrations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ public void Register(Action<Func<object>, Type> registerFunction)

if (!ModeDetector.InUnitTestRunner())
{
RxApp.TaskpoolScheduler = TaskPoolScheduler.Default;
RxApp.MainThreadScheduler = DefaultScheduler.Instance;
RxSchedulers.TaskpoolScheduler = TaskPoolScheduler.Default;
RxSchedulers.MainThreadScheduler = DefaultScheduler.Instance;
}
}
}
Loading
Loading