diff --git a/Samples/Blazor/BlazorSample.Shared/Pages/Counter.razor b/Samples/Blazor/BlazorSample.Shared/Pages/Counter.razor
new file mode 100644
index 00000000..e9be5291
--- /dev/null
+++ b/Samples/Blazor/BlazorSample.Shared/Pages/Counter.razor
@@ -0,0 +1,21 @@
+@page "/counter"
+@using Reactive.Bindings
+@implements IDisposable
+@inject CounterViewModel CounterViewModel
+
+Counter
+
+
Counter
+
+Current count: @CounterViewModel.Counter.Value
+
+
+
+@code {
+ public void Dispose() => CounterViewModel.Dispose();
+}
\ No newline at end of file
diff --git a/Samples/Blazor/BlazorSample.Shared/Pages/Index.razor b/Samples/Blazor/BlazorSample.Shared/Pages/Index.razor
index 612b2405..017b1aa0 100644
--- a/Samples/Blazor/BlazorSample.Shared/Pages/Index.razor
+++ b/Samples/Blazor/BlazorSample.Shared/Pages/Index.razor
@@ -20,9 +20,12 @@
Validation sample
-
+@*
+*@
@@ -59,10 +62,6 @@
{
ValidationViewModel.AddTo(_disposable);
HelloWorldViewModel.AddTo(_disposable);
-
- HelloWorldViewModel.Output
- .Subscribe(_ => InvokeAsync(StateHasChanged))
- .AddTo(_disposable);
}
public void Dispose() => _disposable.Dispose();
diff --git a/Samples/Blazor/BlazorSample.Shared/ViewModels/CounterViewModel.cs b/Samples/Blazor/BlazorSample.Shared/ViewModels/CounterViewModel.cs
new file mode 100644
index 00000000..e30762ef
--- /dev/null
+++ b/Samples/Blazor/BlazorSample.Shared/ViewModels/CounterViewModel.cs
@@ -0,0 +1,31 @@
+using System.Reactive.Disposables;
+using Reactive.Bindings;
+using Reactive.Bindings.Extensions;
+using Reactive.Bindings.TinyLinq;
+
+namespace BlazorSample.Shared.ViewModels;
+public class CounterViewModel : IDisposable
+{
+ private CompositeDisposable _disposables = new();
+ public ReactivePropertySlim Counter { get; }
+
+ public ReactiveCommandSlim IncrementCommand { get; }
+
+ public CounterViewModel()
+ {
+ Counter = new ReactivePropertySlim(0)
+ .AddTo(_disposables);
+
+ IncrementCommand = Counter.Select(x => x < 10)
+ .ToReactiveCommandSlim()
+ .WithSubscribe(Increment, _disposables.Add)
+ .AddTo(_disposables);
+ }
+
+ private void Increment()
+ {
+ Counter.Value++;
+ }
+
+ public void Dispose() => _disposables.Dispose();
+}
diff --git a/Samples/Blazor/BlazorServerApp/Pages/Counter.razor b/Samples/Blazor/BlazorServerApp/Pages/Counter.razor
deleted file mode 100644
index ef23cb31..00000000
--- a/Samples/Blazor/BlazorServerApp/Pages/Counter.razor
+++ /dev/null
@@ -1,18 +0,0 @@
-@page "/counter"
-
-Counter
-
-Counter
-
-Current count: @currentCount
-
-
-
-@code {
- private int currentCount = 0;
-
- private void IncrementCount()
- {
- currentCount++;
- }
-}
diff --git a/Samples/Blazor/BlazorServerApp/Program.cs b/Samples/Blazor/BlazorServerApp/Program.cs
index ae71739c..7f3fd40b 100644
--- a/Samples/Blazor/BlazorServerApp/Program.cs
+++ b/Samples/Blazor/BlazorServerApp/Program.cs
@@ -11,6 +11,7 @@
builder.Services.AddSingleton();
builder.Services.AddTransient();
builder.Services.AddTransient();
+builder.Services.AddTransient();
var app = builder.Build();
diff --git a/Samples/Blazor/BlazorWasmApp/Pages/Counter.razor b/Samples/Blazor/BlazorWasmApp/Pages/Counter.razor
deleted file mode 100644
index ef23cb31..00000000
--- a/Samples/Blazor/BlazorWasmApp/Pages/Counter.razor
+++ /dev/null
@@ -1,18 +0,0 @@
-@page "/counter"
-
-Counter
-
-Counter
-
-Current count: @currentCount
-
-
-
-@code {
- private int currentCount = 0;
-
- private void IncrementCount()
- {
- currentCount++;
- }
-}
diff --git a/Samples/Blazor/BlazorWasmApp/Program.cs b/Samples/Blazor/BlazorWasmApp/Program.cs
index 22be29d8..bdab3f5b 100644
--- a/Samples/Blazor/BlazorWasmApp/Program.cs
+++ b/Samples/Blazor/BlazorWasmApp/Program.cs
@@ -9,6 +9,7 @@
builder.Services.AddTransient();
builder.Services.AddTransient();
+builder.Services.AddTransient();
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
await builder.Build().RunAsync();
diff --git a/Source/Directory.Build.props b/Source/Directory.Build.props
index 42e373db..703659e7 100644
--- a/Source/Directory.Build.props
+++ b/Source/Directory.Build.props
@@ -1,7 +1,7 @@
Reactive.Bindings
- 9.1.1
+ 9.1.2
neuecc xin9le okazuki
https://github.com/runceel/ReactiveProperty
rx mvvm async rx-main reactive
diff --git a/Source/ReactiveProperty.Platform.Blazor/CommandExtensions.cs b/Source/ReactiveProperty.Platform.Blazor/CommandExtensions.cs
index d423a86d..d106ee4e 100644
--- a/Source/ReactiveProperty.Platform.Blazor/CommandExtensions.cs
+++ b/Source/ReactiveProperty.Platform.Blazor/CommandExtensions.cs
@@ -1,5 +1,4 @@
using System.Windows.Input;
-using Microsoft.AspNetCore.Components;
namespace Reactive.Bindings;
@@ -8,82 +7,11 @@ namespace Reactive.Bindings;
///
public static class CommandExtensions
{
- ///
- /// Convert from ReactiveCommand to EventCallback.
- ///
- /// The type argument of EventCallback
- /// The command
- /// EventCallback instance
- public static EventCallback ToEvent(this ReactiveCommand command) => new EventCallback(null, (TValue _) => command.Execute());
-
- ///
- /// Convert from ReactiveCommand to EventCallback.
- ///
- /// The type argument of EventCallback
- /// The command
- /// EventCallback instance
- public static EventCallback ToEvent(this ReactiveCommand command) => new EventCallback(null, command.Execute);
-
- ///
- /// Convert from ReactiveCommand to EventCallback.
- ///
- /// The type argument of EventCallback
- /// The command
- /// EventCallback instance
- public static EventCallback ToEvent(this ReactiveCommandSlim command) => new EventCallback(null, (TValue _) => command.Execute());
-
- ///
- /// Convert from ReactiveCommand to EventCallback.
- ///
- /// The type argument of EventCallback
- /// The command
- /// EventCallback instance
- public static EventCallback ToEvent(this ReactiveCommandSlim command) => new EventCallback(null, command.Execute);
-
- ///
- /// Convert from ReactiveCommand to EventCallback.
- ///
- /// The type argument of EventCallback
- /// The command
- /// EventCallback instance
- public static EventCallback ToEvent(this AsyncReactiveCommand command) => new EventCallback(null, (TValue _) => command.ExecuteAsync());
-
- ///
- /// Convert from ReactiveCommand to EventCallback.
- ///
- /// The type argument of EventCallback
- /// The command
- /// EventCallback instance
- public static EventCallback ToEvent(this AsyncReactiveCommand command) => new EventCallback(null, command.ExecuteAsync);
-
- ///
- /// Convert from ReactiveCommand to EventCallback.
- ///
- /// The command
- /// EventCallback instance
- public static EventCallback ToEvent(this ReactiveCommand command) => new EventCallback(null, () => command.Execute());
-
- ///
- /// Convert from ReactiveCommand to EventCallback.
- ///
- /// The command
- /// EventCallback instance
- public static EventCallback ToEvent(this ReactiveCommandSlim command) => new EventCallback(null, () => command.Execute());
-
- ///
- /// Convert from ReactiveCommand to EventCallback.
- ///
- /// The command
- /// EventCallback instance
- public static EventCallback ToEvent(this AsyncReactiveCommand command) => new EventCallback(null, () => command.ExecuteAsync());
-
///
/// Return a boolean value that is inverted CanExecute method.
///
/// The command.
/// Inverted value of CanExecute method.
- public static bool IsDisabled(this ICommand command)
- {
- return !command.CanExecute(null);
- }
+ public static bool IsDisabled(this ICommand command) =>
+ !command.CanExecute(null);
}