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

Test case for dispatcher failure in .NET8 with new render modes #487

Open
mikeppcom opened this issue Apr 29, 2024 · 6 comments
Open

Test case for dispatcher failure in .NET8 with new render modes #487

mikeppcom opened this issue Apr 29, 2024 · 6 comments

Comments

@mikeppcom
Copy link

DispatcherTest.zip

@mrpmorris
Copy link
Owner

This works for me.

Server

Program.cs

builder.Services.AddFluxor(x => x.ScanAssemblies(typeof(IncrementCounterAction).Assembly));

Client

Program.cs

builder.Services.AddFluxor(x => x.ScanAssemblies(typeof(IncrementCounterAction).Assembly));

Routes.razor

<Fluxor.Blazor.Web.StoreInitializer/>

Counter.Razor

@page "/counter"
@inherits Fluxor.Blazor.Web.Components.FluxorComponent
@inject Fluxor.IState<CounterState> State
@inject Fluxor.IDispatcher Dispatcher

<PageTitle>Counter</PageTitle>

<h1>Counter</h1>

<p role="status">Current count: @State.Value.Count</p>

<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>

Counter.Razor.cs

using Fluxor;

namespace BlazorFluxorApp.Client.Pages;

public partial class Counter
{
    private int currentCount = 0;

    private void IncrementCount()
    {
        Dispatcher.Dispatch(new IncrementCounterAction());
    }
}

[FeatureState]
public record class CounterState(int Count)
{
    public CounterState() : this(Count: 0) { }
}

public class IncrementCounterAction { }

public static class Reducers
{
    [ReducerMethod(typeof(IncrementCounterAction))]
    public static CounterState Reduce(CounterState state) => state with { Count = state.Count + 1 };
}

@mikeppcom
Copy link
Author

mikeppcom commented May 14, 2024 via email

@mrpmorris
Copy link
Owner

BlazorFluxorApp.zip

If you change this counter example and upload then I will do a diff.

@mikeppcom
Copy link
Author

mikeppcom commented May 15, 2024 via email

@mrpmorris
Copy link
Owner

Doesn't they suggest you have the code in the wrong place?

The client doesn't have access to the server's code, whereas the server has access to both server and client.

@mikeppcom
Copy link
Author

mikeppcom commented May 16, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants