All Projects → akarnokd → reactive-extensions

akarnokd / reactive-extensions

Licence: Apache-2.0 license
Extensions to the dotnet/reactive library.

Programming Languages

C#
18002 projects

Projects that are alternatives of or similar to reactive-extensions

crypto-websocket-extensions
🧰 Unified and optimized data structures across cryptocurrency exchanges
Stars: ✭ 31 (-32.61%)
Mutual labels:  reactive, extensions
urx
urx is a stream-based Reactive state management library
Stars: ✭ 18 (-60.87%)
Mutual labels:  reactive
staballoy
Reactive UI framework for Titanium Alloy
Stars: ✭ 18 (-60.87%)
Mutual labels:  reactive
fpEs
Functional Programming for EcmaScript(Javascript)
Stars: ✭ 40 (-13.04%)
Mutual labels:  reactive
purescript-pop
😃 A functional reactive programming (FRP) demo created with PureScript events and behaviors.
Stars: ✭ 33 (-28.26%)
Mutual labels:  reactive
reactive-search
Incremental search using React and RxJS
Stars: ✭ 15 (-67.39%)
Mutual labels:  reactive
reactive-extension
Simple webfilter tracking extension based on Webflux, default use the Jetty container.
Stars: ✭ 15 (-67.39%)
Mutual labels:  reactive
swift-boilerplate
Clean Architecture for iOS projects (Swift + Programmatically UI + MVC + RxSwift + Auto Layout Visual Format + REST + JWT)
Stars: ✭ 14 (-69.57%)
Mutual labels:  extensions
quarkiverse
Repository for contributing to quarkiverse wiki
Stars: ✭ 29 (-36.96%)
Mutual labels:  extensions
live-stream-media-source-extensions
Live stream h264 encoded mp4 video on media source extensions using ffmpeg, node.js, socket.io, and express. Works in chrome, firefox, safari, and android. Not iOS compatible. Work has moved to mse-live-player repo =>
Stars: ✭ 24 (-47.83%)
Mutual labels:  extensions
whatsup
Reactive framework, simple, fast, easy to use!
Stars: ✭ 115 (+150%)
Mutual labels:  reactive
ifunny
Решение для конкурса FunCode Java/Kotlin Challenge
Stars: ✭ 25 (-45.65%)
Mutual labels:  reactive
rxjava2-http
Transmit RxJava2 Flowable over http with non-blocking backpressure
Stars: ✭ 19 (-58.7%)
Mutual labels:  reactive
stimulus reflex
Build reactive applications with the Rails tooling you already know and love.
Stars: ✭ 2,001 (+4250%)
Mutual labels:  reactive
immerx-state
Reactive, fractal and no-nonsense state management with Immer
Stars: ✭ 19 (-58.7%)
Mutual labels:  reactive
drf tweaks
Extensions for Django Rest Framework
Stars: ✭ 77 (+67.39%)
Mutual labels:  extensions
grass-addons
GRASS GIS Addons Repository (Manuals: https://grass.osgeo.org/grass-stable/manuals/addons/ | Linux-logs: https://grass.osgeo.org/addons/grass8/logs/ | Windows logs: https://wingrass.fsv.cvut.cz/grass82/addons/grass-8.2.0/logs/)
Stars: ✭ 64 (+39.13%)
Mutual labels:  extensions
OverlayViewController
A simple way to present your child view controller on top of another one
Stars: ✭ 17 (-63.04%)
Mutual labels:  extensions
statechart
A rust implementation of statecharts: hierarchical, reactive state machines
Stars: ✭ 41 (-10.87%)
Mutual labels:  reactive
AzureFunctions.Extensions
This provides some useful extensions for Azure Functions.
Stars: ✭ 81 (+76.09%)
Mutual labels:  extensions

reactive-extensions

Travis-CI: VSTS: Build Status NuGet: reactive-extensions NuGet version

Extensions to the dotnet/reactive library.

Setup

Install-Package akarnokd.reactive_extensions -Version 0.0.27-alpha

Dependencies

Table of contents

Operators

These operators are available as extension methods on IObservable via the akarnokd.reactive_extensions.ReactiveExtensions static class.

using akarnokd.reactive_extensions;

BlockingEnumerable

Consumes the source observable in a blocking fashion through an IEnumerable.

var source = Observable.Range(1, 5).SubscribeOn(NewThreadScheduler.Default);

foreach (var v in source.BlockingEnumerable()) {
	Console.WriteLine(v);
}
Console.WriteLine("Done");

Since 0.0.4

BlockingSubscribe

Consumes the source observable in a blocking fashion via callbacks or an observer on the caller thread.

Consuming via an IObservable:

var source = Observable.Range(1, 5).SubscribeOn(NewThreadScheduler.Default);

var to = new TestObserver<int>();
source.BlockingSubscribe(to);

to.AssertResult(1, 2, 3, 4, 5);

Consuming via Action delegates:

source.BlockingSubscribe(
    Console.WriteLine, 
	Console.WriteLine, 
	() => Console.WriteLine("Done")
);

Since 0.0.4
See also: BlockingSubscribeWhile

BlockingSubscribeWhile

Consumes the source observable in a blocking fashion on the current thread and relays events to the given callback actions while the onNext predicate returns true.

source.BlockingSubscribe(v => {
    Console.WriteLine(v);
    return v == 3;
}, Console.WriteLine, () => Console.WriteLine("Done"));

Since 0.0.4
See also: BlockingSubscribe

Cache

Subscribes once to the upstream when the first observer subscribes to the operator, buffers all upstream events and relays/replays them to current or late observers.

var count = 0;

var cached = Observable.Range(1, 5)
.DoOnSubscribe(() => count++)
.Cache();

// not yet subscribed to Range()
Assert.AreEqual(0, count);

// relays events live
cached.Test().AssertResult(1, 2, 3, 4, 5);

Assert.AreEqual(1, count);

// replays the buffered events
cached.Test().AssertResult(1, 2, 3, 4, 5);

// no further subscriptions
Assert.AreEqual(1, count);

Since 0.0.4

Collect

Collects upstream items into a per-observer collection object created via a function and added via a collector action and emits this collection when the upstream completes.

Observable.Range(1, 5)
.Collect(() => new List<int>(), (a, b) => a.Add(b))
.Test()
.AssertResult(new List<int>() { 1, 2, 3, 4, 5 });

Since: 0.0.3

CombineLatest

Combines the latest items of each source observable through a mapper function, optionally delaying errors until all of them terminates.

ReactiveExtensions.CombineLatest(a => a, source1, source);

new [] { source1, source2 }.CombineLatest(a => a, true);

Since: 0.0.5

Compose

Applies a function to the source at assembly-time and returns the observable returned by this function. This allows creating reusable set of operators to be applied on observables.

Func<IObservable<int>, IObservable<int>> applySchedulers =
    o => o.SubscribeOn(Scheduler.NewThread).ObserveOn(Scheduler.UI);

var o1 = Observable.Range(1, 5).Compose(applySchedulers);
var o2 = Observable.Range(10, 5).Compose(applySchedulers);
var o3 = Observable.Range(20, 5).Compose(applySchedulers);

Since: 0.0.3

ConcatEager

Concatenates a sequence of observables eagerly by running some or all of them at once and emitting their items in order. It is equivalent to sources.ConcatMapEager(v => v).

new[] 
{
    Observable.Range(1, 5),
    Observable.Range(6, 5),
    Observable.Range(11, 5)
}
.ToObservable()
.ConcatEager()
.Test()
.AssertResult(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);

Since: 0.0.3
See also: ConcatMapEager

ConcatMap

Maps the upstream values into enumerables and emits their items in-order.

ConcatMany

Concatenates (flattens) a sequence of observables.

ConcatMapEager

Maps the upstream values into observables, runs some or all of them at once and emits items of one such observable until it completes, then switches to the next observable, and so on until no more observables are running.

Since: 0.0.2
See also: ConcatEager

Create

Creates an observable sequence by providing an emitter API to bridge the callback world with the reactive world.

ReactiveExtensions.Create(emitter => {

	Task.Factory.StartNew(() => {
		for (int i = 0; i < 1000; i++) {
		    if (emitter.IsDisposed()) {
				return;
			}
			emitter.OnNext(1);
		}
	    if (emitter.IsDisposed()) {
			return;
		}
		emitter.OnCompleted();
	});

}, true)
.Test()
.AwaitDone(TimeSpan.FromSeconds(5))
.AssertValueCount(1000)
.AssertNoError()
.AssertCompleted();

Since: 0.0.5

DoAfterNext

Call a handler after the current item has been emitted to the downstream.

DoAfterTerminate

Call a handler after the upstream terminated normally or with an error.

DoOnSubscribe

Call a handler just before the downstream subscribes to the upstream.

DoOnDispose

Call a handler when the downstream disposes the sequence.

DoFinally

Call a handler after the upstream terminates normally, with an error or the downstream disposes the sequence.

IntervalRange

Emits a range of values over time.

ReactiveExtensions.IntervalRange(1, 5, 
    TimeSpan.FromSeconds(1), TimeSpan.FromSecoconds(2), NewThreadScheduler.Default)
	.Test()
	.AwaitDone(TimeSpan.FromSeconds(12))
	.AssertResult(1, 2, 3, 4, 5);

MergeMany

Merges some or all inner observables provided via an observable sequence and emits their items in a sequential manner.

ObserveOn

Observe the signals of the upstream on a specified scheduler and optionally delay any error after all upstream items have been delivered.

(The standard ObserveOn by default allows errors to cut ahead.)

Repeat

Repeatedly re-subscribes to the source observable if the predicate function returns true upon the completion of the previous subscription.

Since: 0.0.3

Retry

Repeatedly re-subscribes to the source observable if the predicate function returns true upon the failure of the previous subscription.

Since: 0.0.3

SwitchIfEmpty

Switches to the (next) fallback observable if the main source or a previous fallback is empty.

var source = new Subject<int>();

var to = source.SwitchIfEmpty(Observable.Range(1, 5)).Test();

source.OnCompleted();

to.AssertResult(1, 2, 3, 4, 5);

Since: 0.0.3

SwitchMany

Switches to a new inner observable when the outer observable produces one, disposing the previous active observable. The operator can be configured to delay all errors until all sources have terminated.

Since: 0.0.4
See also: SwitchMap

SwitchMap

Switches to a new observable mapped via a function in response to an new upstream item, disposing the previous active observable. The operator can be configured to delay all errors until all sources have terminated.

Since: 0.0.4
See also: SwitchMany

Test

Subscribe a TestObserver to the observable sequence to perform various convenient assertions.

ToSerialized

Wraps an IObserver or an ISubject and serializes the calls to its OnNext, OnError and OnCompleted methods by making sure they are called non-overlappingly and non-concurrently.

UnsubscribeOn

Makes sure the Dispose() call towards the upstream happens on the specified scheduler.

Since: 0.0.4

WithLatestFrom

Combines the latest values of multiple alternate observables with the value of the main observable sequence through a function. Unlike CombineLatest, new items from the alternate observables do not trigger an emission. The operator can optionally delay errors from the alternate sources until the main source terminates.

Since: 0.0.4

Zip

Combines the next item of each source observable (a row of values) through a mapper function, optionally delaying errors until no more rows can be created.

ReactiveExtensions.Zip(a => a, source1, source);

new [] { Observable.Range(1, 5), Observable.Range(1, 10) }
.Zip(a => a[0] + a[1], true)
.Test()
.AssertResult(2, 4, 6, 8, 10);

Since: 0.0.5

Other classes

TestObserver

An IObserver that offers a bunch of AssertX methods to check what signals has been received from the upstream as well as have some trivial output checks in a more convenient fashion.

var to = new TestObserver<int>();

Observable.Range(1, 5).Subscribe(to);

to.AssertResult(1, 2, 3, 4, 5);

There is the Test() extension method to make this more convenient in some cases:

Observable.Range(1, 5)
.Test()
.AwaitDone(TimeSpan.FromSeconds(5))
.AssertResult(1, 2, 3, 4 ,5)

TestScheduler

An IScheduler implementation that allows manually advancing a virtual time and thus executing tasks up to a certain due time.

var scheduler = new TestScheduler();

var to = Observable.IntervalRange(1, 5, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(2), scheduler)
.Test();

to.AssertEmpty();

scheduler.AdvanceTimeBy(TimeSpan.FromSeconds(1));

to.AssertValuesOnly(1);

scheduler.AdvanceTimeBy(TimeSpan.FromSeconds(4));

to.AssertValuesOnly(1, 2, 3);

scheduler.AdvanceTimeBy(TimeSpan.FromSeconds(4));

to.AssertResult(1, 2, 3, 4, 5);

Assert.False(scheduler.HasTasks());

Since 0.0.6

UnicastSubject

A special ISubject that supports exactly one IObserver during the subject's lifetime and buffers signals until such observer subscribes to it.

ICompletableSource

A reactive type which signals an OnCompleted() or an OnError(), no items.

Consumer type: ICompletableObserver

Extension methods host: CompletableSource

Since: 0.0.5

Factory methods

  • Amb
  • AmbAll
  • Concat
  • ConcatAll
  • Create
  • Defer
  • Empty
  • Error
  • FromAction
  • FromTask
  • Merge
  • MergeAll
  • Never
  • Timer
  • Using

Instance methods

  • AndThen
  • Compose
  • Cache
  • Delay
  • DelaySubscription
  • DoAfterTerminate
  • DoFinally
  • DoOnCompleted
  • DoOnDispose
  • DoOnError
  • DoOnSubscribe
  • DoOnTerminate
  • ObserveOn
  • OnErrorComplete
  • OnErrorResumeNext
  • OnTerminateDetach
  • Repeat
  • RepeatWhen
  • Retry
  • RetryWhen
  • SubscribeOn
  • TakeUntil
  • Timeout
  • UnsubscribeOn

Consumer methods

  • BlockingSubscribe
  • Subscribe
  • SubscribeSafe
  • SubscribeWith
  • Test
  • Wait

Interoperation

  • AndThen (with IObservable, ISingleSource & IMaybeSource)
  • ConcatMap (on Observable)
  • FlatMap (on Observable)
  • IgnoreAllElements (on IObservable)
  • SwitchMap (on Observable)
  • ToCompletable (on Task)
  • ToMaybe
  • ToObservable
  • ToSingle
  • ToTask

CompletableSubject

A completable-based, hot subject that multicasts the termination event it receives through its completable observer API surface.

This subject supports an optional reference-counting behavior: when all completable observers dispose before the subject terminates, it will terminate its upstream connection (if any).

Since 0.0.6

ISingleSource

A reactive type wich signals an OnSuccess() or an OnError().

Consumer type: ISingleObserver<T>

Extension methods host: SingleSource

Since: 0.0.5

Factory methods

  • Amb
  • AmbAll
  • Concat
  • ConcatAll
  • ConcatEager
  • ConcatEagerAll
  • Create
  • Defer
  • Error
  • FromFunc
  • FromTask
  • Just
  • Merge
  • MergeAll
  • Never
  • Timer
  • Using
  • Zip

Instance methods

  • Compose
  • Filter
  • FlatMap
  • Cache
  • Delay
  • DelaySubscription
  • DoAfterSuccess
  • DoAfterTerminate
  • DoOnDispose
  • DoOnError
  • DoOnSubscribe
  • DoOnSuccess
  • DoOnTerminate
  • FlatMap (onto IEnumerable, ISingleSource)
  • Map
  • ObserveOn
  • OnErrorResumeNext
  • OnTerminateDetach
  • Repeat
  • RepeatWhen
  • Retry
  • RetryWhen
  • SubscribeOn
  • SubscribeSafe
  • TakeUntil
  • Timeout
  • UnsubscribeOn

Consumer methods

  • BlockingSubscribe
  • Subscribe
  • SubscribeSafe
  • SubscribeWith
  • Test
  • Wait

Interoperation

  • ConcatMap (on IObservable)
  • ConcatMapEager (on IObservable)
  • ElementAtOrDefault
  • ElementAtOrError
  • FirstOrDefault
  • FirstOrError
  • FlatMap (onto ICompletableSource, IMaybeSource, IObservable)
  • IgnoreElement
  • LastOrDefault
  • LastOrError
  • SingleOrDefault
  • SingleOrError
  • SwitchMap (on IObservable)
  • ToMaybe
  • ToObservable
  • ToSingle
  • ToTask

SingleSubject

A single-based, hot subject that multicasts the value or failure event it receives through its single observer API surface.

This subject supports an optional reference-counting behavior: when all single observers dispose before the subject succeeds or fails, it will terminate its upstream connection (if any).

Since 0.0.9

IMaybeSource

A reactive type wich signals an OnSuccess(), an OnError() or an OnCompleted() in a mutually exclusive fashion.

Consumer type: IMaybeObserver<T>

Extension methods host: MaybeSource

Since: 0.0.5

Factory methods

  • Amb
  • Create
  • Concat
  • ConcatAll
  • ConcatEager
  • ConcatEagerAll
  • Defer
  • Empty
  • Error
  • FromAction
  • FromFunc
  • FromTask
  • Just
  • Merge
  • MergeAll
  • Never
  • Timer
  • Using
  • Zip

Instance methods

  • Cache
  • Compose
  • DefaultIfEmpty
  • Delay
  • DelaySubscription
  • DoAfterSuccess
  • DoAfterTerminate
  • DoFinally
  • DoOnCompleted
  • DoOnDispose
  • DoOnError
  • DoOnSubscribe
  • DoOnSuccess
  • DoOnTerminate
  • Filter
  • Map
  • ObserveOn
  • OnErrorComplete
  • OnErrorResumeNext
  • OnTerminateDetach
  • Repeat
  • RepeatWhen
  • Retry
  • RetryWhen
  • SubscribeOn
  • SwitchIfEmpty
  • TakeUntil
  • Timeout
  • UnsubscribeOn

Consumer methods

  • BlockingSubscribe
  • Subscribe
  • SubscribeSafe
  • SubscribeWith
  • Test
  • Wait

Interoperation

  • ConcatMap (on IObservable)
  • ConcatMapEager (on IObservable)
  • ElementAtIndex (on IObservable)
  • FirstElement (on IObservable)
  • FlatMap (onto ICompletableSource, ISingleSource, IObservable, IEnumerable)
  • FlatMap (on IObservable)
  • IgnoreElement
  • LastElement (on IObservable)
  • SingleElement (on IObservable)
  • SwitchMap (on IObservable)
  • ToObservable
  • ToSingle
  • ToTask

MaybeSubject

A maybe-based, hot subject that multicasts the value or termination event it receives through its maybe observer API surface.

This subject supports an optional reference-counting behavior: when all maybe observers dispose before the subject succeeds or terminates, it will terminate its upstream connection (if any).

Since 0.0.9

IObservableSource

Since 0.0.17

A fully push-based observable source implementation that fixes the issues with the IObservable interface.

Consumer type: ISignalObserver (may change)

Main differences:

  • IObservable.Subscribe is now void and thus fire-and-forget. Works both in synchronous and asynchronous cases because cancellation is now pushed down,
  • ISignalObserver.OnSubscribe receives a Disposable upfront so it can be cancelled synchronously and asynchronously.

Factory methods

  • Amb
  • CombineLatest
  • Concat
  • ConcatEager
  • Create
  • Defer
  • Empty
  • Error
  • FromAction
  • FromArray
  • FromFunc
  • Interval
  • IntervalRange
  • Just
  • Merge
  • Never
  • Range
  • RangeLong
  • Switch
  • Timer
  • Using
  • Zip

Instance methods

  • All
  • Any
  • Buffer
  • Cache
  • Collect
  • Compose
  • ConcatMap
  • ConcatMapEager
  • Delay
  • DelaySubscription
  • DoAfterNext
  • DoAfterTerminate
  • DoFinally
  • DoOnCompleted
  • DoOnDispose
  • DoOnError
  • DoOnNext
  • DoOnSubscribe
  • DoOnTerminate
  • ElementAt
  • Filter
  • First
  • FlatMap
  • GroupBy
  • Hide
  • IgnoreElements
  • IsEmpty
  • Join
  • Last
  • Map
  • Max
  • Min
  • Multicast
  • ObserveOn
  • OnErrorResumeNext
  • OnTerminateDetach
  • Publish
  • Reduce
  • Repeat
  • RepeatWhen
  • Replay
  • Retry
  • RetryWhen
  • Single
  • Skip
  • SkipLast
  • SkipUntil
  • SkipWhile
  • SubscribeOn
  • Sum
  • SwitchIfEmpty
  • SwitchMap
  • Take
  • TakeLast
  • TakeUntil
  • TakeWhile
  • Timeout
  • ToDictionary
  • ToList
  • ToLookup
  • UnsubscribeOn
  • Window
  • WithLatestFrom

Consumer methods

  • BlockingEnumerable
  • BlockingSubscribe
  • BlockingSubscribeWhile
  • BlockingFirst
  • BlockingLast
  • BlockingSingle
  • BlockingTryFirst
  • BlockingTryLast
  • BlockingTrySingle
  • Subscribe
  • SubscribeWith
  • Test

Interoperation with other async types

  • ElementAtTask
  • FirstTask
  • FromTask
  • IgnoreElementsTask
  • LastTask
  • SingleTask
  • ToObservableSource (on T[], IObservable, IEnumerable, Task)
  • ToObservable (into IObservable)

IConnectableObservableSource

Represents an observable source that can be connected and disconnected from, allowing signal observers to gather up before the flow starts.

  • AutoConnect
  • RefCount

PublishSubject

Multicasts the same items to one or more currently subscribed observers (same as an Rx.NET Subject).

MonocastSubject

Buffers items until a single observer subscribes and replays/relays all items to it.

CacheSubject

Caches some or all items and relays/replays it to current or future observers.

IAsyncEnumerable

Removed in 0.0.28

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].