Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: Enable WASM on Blazor #2295

Merged
merged 10 commits into from Jan 1, 2020
6 changes: 2 additions & 4 deletions src/ReactiveUI.Blazor/ReactiveUI.Blazor.csproj
@@ -1,5 +1,4 @@
<Project Sdk="MSBuild.Sdk.Extras">

<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<PackageDescription>Contains the ReactiveUI platform specific extensions for Blazor</PackageDescription>
Expand All @@ -8,11 +7,10 @@

<ItemGroup>
<PackageReference Include="Reactive.Wasm" Version="1.*" />
<PackageReference Include="Microsoft.AspNetCore.Components" Version="3.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Components" Version="3.1.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\ReactiveUI\ReactiveUI.csproj" />
glennawatson marked this conversation as resolved.
Show resolved Hide resolved
<ProjectReference Include="..\ReactiveUI\ReactiveUI.csproj" />
</ItemGroup>

</Project>
17 changes: 5 additions & 12 deletions src/ReactiveUI.Blazor/Registrations.cs
Expand Up @@ -4,10 +4,8 @@
// See the LICENSE file in the project root for full license information.

using System;
using System.Collections.Generic;
using System.Reactive.Concurrency;
using System.Reactive.PlatformServices;
using System.Text;

namespace ReactiveUI.Blazor
{
Expand All @@ -27,18 +25,13 @@ public void Register(Action<Func<object>, Type> registerFunction)

registerFunction(() => new PlatformOperations(), typeof(IPlatformOperations));

#if NETSTANDARD
if (WasmPlatformEnlightenmentProvider.IsWasm)
if (Type.GetType("Mono.Runtime") != null)
{
RxApp.TaskpoolScheduler = WasmScheduler.Default;
RxApp.MainThreadScheduler = WasmScheduler.Default;
}
else
#endif
{
RxApp.TaskpoolScheduler = TaskPoolScheduler.Default;
RxApp.MainThreadScheduler = new WaitForDispatcherScheduler(() => CurrentThreadScheduler.Instance);
PlatformEnlightenmentProvider.Current.EnableWasm();
}

RxApp.TaskpoolScheduler = TaskPoolScheduler.Default;
RxApp.MainThreadScheduler = new WaitForDispatcherScheduler(() => CurrentThreadScheduler.Instance);
glennawatson marked this conversation as resolved.
Show resolved Hide resolved
}
}
}