Skip to content

Extensions from STDev. Target is .NET 4.6, UWP, Xamarin(Android, iOS, Forms) and .NET Standard 1.3.

License

Notifications You must be signed in to change notification settings

STDevTM/STDevExt

Repository files navigation

STDevExt

Extensions from STDev. Target is .NET 4.6, UWP, Xamarin(Android, iOS, Forms) and .NET Standard 1.3.

Version Downloads

Supported Platforms

STDevExt supports the following platforms

  • .NET Framework 4.6+
  • .NET Standard 1.3+ (including .NET Core, Xamarin and others)
  • UWP

Installation

STDevRxExt is available through NuGet. To install it, simply run the following command to your Package Manager Console:

PM> Install-Package STDevExt

Usage

Add following in top of your file:

using STDevExt.Extensions;

List of All Extensions

Collection Extensions

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

Rx Extensions

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 use WhereNull 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 use WhereFalse 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

Author

Tigran Hambardzumyan, tigran@stdevmail.com

Support

Feel free to open issuses with any suggestions, bug reports, feature requests, questions.

Let us know!

We’d be really happy if you sent us links to your projects where you use our component. Just send an email to developer@stdevmail.com And do let us know if you have any questions or suggestion.

License

STDevRxExt is available under the MIT license. See the LICENSE file for more info.

About

Extensions from STDev. Target is .NET 4.6, UWP, Xamarin(Android, iOS, Forms) and .NET Standard 1.3.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published