Why FSharp.Control.Reactive not work in Fable?

I wanted to use something like this:

let count = Subject.behavior(0)
count.OnNext(count.Value + 1)

But compiler failed with error:

error FSHARP: The type referenced through ‘System.Reactive.Subjects.BehaviorSubject`1’ is defined in an assembly that is not referenced. You must add a reference to assembly ‘System.Reactive’

Hi!

My guess would be that since FSharp.Control.Reactive is just an F# style wrapper for another package, you also need to add the original package to your project. Have you added the System.Reactive package? :slight_smile:

dotnet add package System.Reactive --version 6.0.0

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <Compile Include="App.fs" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="Fable.Browser.Dom" Version="2.2.0" />
    <PackageReference Include="Fable.Core" Version="3.2.3" />
    <PackageReference Include="FSharp.Control.Reactive" Version="5.0.5" />
    <PackageReference Include="System.Reactive" Version="6.0.0" />
  </ItemGroup>
</Project>

./src/App.fs(6,13): (6,32) error FSHARP: The type referenced through ‘System.Reactive.Subjects.BehaviorSubject`1’ is defined in an assembly that is not referenced. You must add a reference to assembly ‘System.Reactive’. (code 74)
./src/App.fs(11,1): (11,16) error FSHARP: Lookup on object of indeterminate type based on information prior to this program point. A type annotation may be needed prior to this program point to constrain the type of the object. This may allow the lookup to be resolved. (code 72)
./src/App.fs(14,5): (14,17) error FSHARP: Lookup on object of indeterminate type based on information prior to this program point. A type annotation may be needed prior to this program point to constrain the type of the object. This may allow the lookup to be resolved. (code 72)