chore: Add NotNull extension method for IObservable

The main purpose of this is to force type `T` to not be nullable. If you
just use `Where()`, then you still get `IObservable<T?>`.
pull/92/head
Robert Dailey 2 years ago
parent 5b0b0be5b6
commit 87830303ae

@ -43,4 +43,11 @@ public static class RxExtensions
}
});
}
// Borrowed from: https://stackoverflow.com/a/59434717/157971
public static IObservable<T> NotNull<T>(this IObservable<T?> observable)
where T : class
{
return observable.Where(x => x is not null).Select(x => x!);
}
}

Loading…
Cancel
Save