From 00ed32f9295c7a5f6c823ac22dc4bfe6e71dd41e Mon Sep 17 00:00:00 2001 From: Justin Swanson Date: Sun, 13 Oct 2019 01:38:51 -0500 Subject: [PATCH] Some comments --- Wabbajack/AppState.cs | 1 + Wabbajack/Extensions/ReactiveUIExt.cs | 32 +++++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/Wabbajack/AppState.cs b/Wabbajack/AppState.cs index 7e08f627..4022464e 100644 --- a/Wabbajack/AppState.cs +++ b/Wabbajack/AppState.cs @@ -130,6 +130,7 @@ namespace Wabbajack this.WhenAny(x => x.ModListPath), this.WhenAny(x => x.EnableSlideShow), (modList, modListPath, enableSlideShow) => (modList, modListPath, enableSlideShow)) + // Do any potential unzipping on a background thread .ObserveOn(RxApp.TaskpoolScheduler) .Select(u => { diff --git a/Wabbajack/Extensions/ReactiveUIExt.cs b/Wabbajack/Extensions/ReactiveUIExt.cs index 7274bca3..a86a9827 100644 --- a/Wabbajack/Extensions/ReactiveUIExt.cs +++ b/Wabbajack/Extensions/ReactiveUIExt.cs @@ -11,6 +11,15 @@ namespace Wabbajack { public static class ReactiveUIExt { + /// + /// Convenience function to not have to specify the selector function in the default ReactiveUI WhenAny() call. + /// Subscribes to changes in a property on a given object. + /// + /// Type of object to watch + /// The type of property watched + /// Object to watch + /// Expression path to the property to subscribe to + /// public static IObservable WhenAny( this TSender This, Expression> property1) @@ -19,17 +28,31 @@ namespace Wabbajack return This.WhenAny(property1, selector: x => x.GetValue()); } + /// + /// Convenience function that discards events that are null + /// + /// + /// + /// Source events that are not null public static IObservable NotNull(this IObservable source) where T : class { return source.Where(u => u != null); } + /// + /// Convenience wrapper to observe following calls on the GUI thread. + /// public static IObservable ObserveOnGuiThread(this IObservable source) { return source.ObserveOn(RxApp.MainThreadScheduler); } + /// + /// Converts any observable to type Unit. Useful for when you care that a signal occurred, + /// but don't care about what its value is downstream. + /// + /// An observable that returns Unit anytime the source signal fires an event. public static IObservable Unit(this IObservable source) { return source.Select(_ => System.Reactive.Unit.Default); @@ -40,7 +63,6 @@ namespace Wabbajack /// When the switch is on, the source will be subscribed to, and its updates passed through. /// When the switch is off, the subscription to the source observable will be stopped, and no signal will be published. /// - /// /// Source observable to subscribe to if on /// On/Off signal of whether to subscribe to source observable /// Observable that publishes data from source, if the switch is on. @@ -64,12 +86,18 @@ namespace Wabbajack /// These snippets were provided by RolandPheasant (author of DynamicData) /// They'll be going into the official library at some point, but are here for now. - #region Dynamic Data EnsureUniqueChanges + #region Dynamic Data EnsureUniqueChanges + /// + /// Removes outdated key events from a changeset, only leaving the last relevent change for each key. + /// public static IObservable> EnsureUniqueChanges(this IObservable> source) { return source.Select(EnsureUniqueChanges); } + /// + /// Removes outdated key events from a changeset, only leaving the last relevent change for each key. + /// public static IChangeSet EnsureUniqueChanges(this IChangeSet input) { var changes = input