Last active
May 15, 2018 12:45
-
-
Save reniris/e68089c80df076ac6705340e2bb63597 to your computer and use it in GitHub Desktop.
インデクサをIObservable<T>に変更する拡張メソッド
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class PropertyChangedExtensions | |
{ | |
public static IObservable<PropertyChangedEventArgs> ObserveIndexer(this INotifyPropertyChanged self, string indexerName = "Item") | |
{ | |
return Observable.FromEvent<PropertyChangedEventHandler, PropertyChangedEventArgs>( | |
h => (s, e) => h(e), | |
h => self.PropertyChanged += h, | |
h => self.PropertyChanged -= h) | |
.Where(e => e.PropertyName == indexerName); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment