Extensions from STDev. Target is .NET 4.6, UWP, Xamarin(Android, iOS, Forms) and .NET Standard 1.3.
STDevExt supports the following platforms
- .NET Framework 4.6+
- .NET Standard 1.3+ (including .NET Core, Xamarin and others)
- UWP
STDevRxExt is available through NuGet. To install it, simply run the following command to your Package Manager Console:
PM> Install-Package STDevExt
Add following in top of your file:
using STDevExt.Extensions;
- Collection Extensions
- Rx Extensions
- more coming soon
Inserting
Insert element to IList
to provided index and return result:
IList<string> list = new List<string>()
.Inserting(0, "second")
.Inserting(0, "first");
list.ToList().ForEach(element => Debug.WriteLine(element));
Output will be:
first
second
Adding
Add element to end of ICollection
and return result:
ICollection<string> list = new List<string>()
.Adding("first")
.Adding("second");
list.ToList().ForEach(element => Debug.WriteLine(element));
Output will be:
first
second
WhereNotNull
Filter IEnumerable
and keep only not null
elements:
IEnumerable<string> list = new List<string>()
.Adding("first")
.Adding(null)
.Adding("second")
.WhereNotNull();
list.ToList().ForEach(element => Debug.WriteLine(element));
Output will be:
first
second
WhereNotNull
Filter IObservable
and keep only not null
elements:
Subject<string> subject = new Subject<string>();
subject
.WhereNotNull()
.Subscribe(element => Debug.WriteLine(element));
subject.OnNext("first");
subject.OnNext(null);
subject.OnNext("second");
Output will be:
first
second
If you prefer only
null
elements you can useWhereNull
method.
WhereNotEmpty
Filter IObservable<string | ICollection>
and keep only not empty elements:
Subject<string> subject = new Subject<string>();
subject
.WhereNotEmpty()
.Subscribe(element => Debug.WriteLine(element));
subject.OnNext("first");
subject.OnNext("");
subject.OnNext("second");
Output will be:
first
second
If you prefer only empty elements you can use
WhereEmpty
method.
WhereTrue
Filter IObservable<bool>
and keep only true
elements:
Subject<bool> subject = new Subject<bool>();
subject
.WhereTrue()
.Subscribe(element => Debug.WriteLine(element));
subject.OnNext(true);
subject.OnNext(false);
subject.OnNext(true);
subject.OnNext(true);
subject.OnNext(false);
Output will be:
True
True
True
If you prefer only
false
elements you can useWhereFalse
method.
SelectTo
Map IObservable
all elements with provided value:
Subject<bool> subject = new Subject<bool>();
subject
.SelectTo("ping")
.Subscribe(element => Debug.WriteLine(element));
subject.OnNext(true);
subject.OnNext(false);
subject.OnNext(true);
subject.OnNext(true);
subject.OnNext(false);
Output will be:
ping
ping
ping
ping
ping
Tigran Hambardzumyan, [email protected]
Feel free to open issuses with any suggestions, bug reports, feature requests, questions.
We’d be really happy if you sent us links to your projects where you use our component. Just send an email to [email protected] And do let us know if you have any questions or suggestion.
STDevRxExt is available under the MIT license. See the LICENSE file for more info.