Reaction 0.4.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Reaction --version 0.4.0
NuGet\Install-Package Reaction -Version 0.4.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Reaction" Version="0.4.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Reaction --version 0.4.0
#r "nuget: Reaction, 0.4.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Reaction as a Cake Addin
#addin nuget:?package=Reaction&version=0.4.0

// Install Reaction as a Cake Tool
#tool nuget:?package=Reaction&version=0.4.0

re·ac·tion

Reaction is a lightweight Async Reactive (Rx) library for F# targeting Fable. This means that the code may be transpiled to JavaScript, and thus the same F# code may be used both client and server side for full stack software development.

Currently a playground project for experimenting with async reactive functional programming (Async Observables) in F#. The project is heavily inspired by aioreactive.

See Fable Reaction for Elmish-ish use of Reaction.

Install

paket add Reaction --project <project>

Async Observables

Reaction is an implementation of Async Observable. The difference between an "Async Observable" and an "Observable" is that with "Async Observables" you need to await operations such as Subscribe, OnNext, OnError, OnCompleted. This enables Subscribe to await async operations i.e setup network connections, and observers may finally await side effects such as writing to disk (observers are all about side-effects right?).

Reaction is built upon simple functions instead of classes and the traditional Rx interfaces. Some of the operators uses mailbox processors (actors) to implement the observer pipeline in order to avoid locks and mutables. This makes the code more Fable friendly. Here are the core types:

type Notification<'a> =
    | OnNext of 'a
    | OnError of exn
    | OnCompleted

type AsyncDisposable = unit -> Async<unit>
type AsyncObserver<'a> = Notification<'a> -> Async<unit>
type AsyncObservable<'a> = AsyncObserver<'a> -> Async<AsyncDisposable>

Usage

open Reaction

let main = async {
    let mapper x =
        x * 10

    let xs = single 42 |> map mapper
    let obv n =
        match n with
        | OnNext x -> printfn "OnNext: %d" x
        | OnError ex -> printfn "OnError: %s" ex.ToString()
        | OnCompleted -> printfn "OnCompleted"

    let! subscription = xs.SubscribeAsync obv
}

Async.Start main

Operators

The following parameterized async observerable returning functions (operators) are currently supported. Other operators may be implemented on-demand, but there are currently no plans to make this into a full featured Rx implementation.

  • map, mapi, mapAsync, mapiAsync
  • filter, filterAsync
  • scan, scanAsync
  • merge
  • flatMap, flatMapi, flatMapAsync, flatMapiAsync
  • concat
  • startWith
  • distinctUntilChanged
  • delay
  • debounce
  • combineLatest
  • withLatestFrom
  • switchLatest
  • catch
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Reaction:

Package Downloads
Reaction.Giraffe

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 2,026 10/20/2018
0.13.1 1,357 10/1/2018
0.13.0 767 9/30/2018
0.12.3 922 9/27/2018
0.11.0 892 9/20/2018
0.10.0 762 9/15/2018
0.9.1 951 9/5/2018
0.9.0 702 9/5/2018
0.8.2 915 9/4/2018
0.8.1 756 9/2/2018
0.8.0 848 9/2/2018
0.7.0 740 9/1/2018
0.6.0 726 9/1/2018
0.5.0 714 8/31/2018
0.4.0 842 8/29/2018
0.3.0 691 8/28/2018
0.2.0 689 8/26/2018
0.1.0 772 8/15/2018