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

Add async overload of SubscribeToAction #533

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

pcannon-b2w
Copy link

When using FluxorComponent.SubscribeToAction to work with mutable objects (such as DTO's), I often need to transition into async code. An example would be where we are binding a DataGrid to a DTO. The 3rd party components methods for refreshing are asynchronous.

In this scenario, it would really useful to have an async variant for the SubscribeToAction method, replacing the Action<TAction> callback parameter with Func<TAction, Task> callback and then awaiting this inside of InvokeAsync. This avoids StateHasChanged being called before the handler has fully completed.

In my own project, I have a custom version of FluxorComponent where we have implemented this and it is working well. I wanted to suggest adding this to the base component.

Renamed method to avoid breaking changes and be consistent with Blazor naming convention
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

Successfully merging this pull request may close these issues.

1 participant