File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed
StabilityMatrix.Core/Services Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -91,6 +91,15 @@ IDisposable RegisterPropertyChangedHandler<T>(
9191 Action < T > onPropertyChanged
9292 ) ;
9393
94+ /// <summary>
95+ /// Creates an observable sequence that notifies when the specified settings property changes.
96+ /// Emits the initial value upon subscription and subsequent changes.
97+ /// </summary>
98+ /// <typeparam name="T">The type of the property value.</typeparam>
99+ /// <param name="settingsProperty">An expression representing the settings property to observe.</param>
100+ /// <returns>An observable sequence of the property's values.</returns>
101+ IObservable < T > ObservePropertyChanged < T > ( Expression < Func < Settings , T > > settingsProperty ) ;
102+
94103 /// <summary>
95104 /// Attempts to locate and set the library path
96105 /// Return true if found, false otherwise
Original file line number Diff line number Diff line change @@ -301,6 +301,20 @@ Action<T> onPropertyChanged
301301 } ) ;
302302 }
303303
304+ /// <inheritdoc />
305+ public IObservable < T > ObservePropertyChanged < T > ( Expression < Func < Settings , T > > settingsProperty )
306+ {
307+ var settingsAccessor = CompiledExpression . CreateAccessor ( settingsProperty ) ;
308+
309+ return Observable
310+ . FromEventPattern < EventHandler < RelayPropertyChangedEventArgs > , RelayPropertyChangedEventArgs > (
311+ h => SettingsPropertyChanged += h ,
312+ h => SettingsPropertyChanged -= h
313+ )
314+ . Where ( args => args . EventArgs . PropertyName == settingsAccessor . FullName )
315+ . Select ( _ => settingsAccessor . Get ( Settings ) ) ;
316+ }
317+
304318 /// <summary>
305319 /// Attempts to locate and set the library path
306320 /// Return true if found, false otherwise
You can’t perform that action at this time.
0 commit comments