mrpmorris / Fluxor

Fluxor is a zero boilerplate Flux/Redux library for Microsoft .NET and Blazor.
MIT License
1.27k stars 146 forks source link

Subscribe to Action in ASP.NET Blazor server #396

Closed nthompson0033 closed 1 year ago

nthompson0033 commented 1 year ago

Hello I have used Fluxor server to communicate between two Hosted background services in an ASP.NET Blazor server applixcation

My Fluxor service is installed as a singleton

Each action subscription is dispatched but not actioned untill a browser connects to the application, but I need the services to run with or without a user interface

Is this by design, or a feature of the singleton service is there an alternative configuration for the fluxor service, please advise many thanks I can supply any code if you let me know what you need many thanks Nick.

nthompson0033 commented 1 year ago

Hi It may be an issue with the location of StoreInitialiser (which is in app.razor) any suggestion would be great I will experiment further when I am able too Nick

mrpmorris commented 1 year ago

Fluxor is thread safe, but I don't think it would be a very effective way of having multiple users share a single state.

In answer to your question, you can call IStore.InitializeAsync() when your server starts.

nthompson0033 commented 1 year ago

Thankyou Peter for your quick response, I was having a quick panic as my whole project design was falling apart, I have three hosted services & calling ISore.InitializeAsync as you suggest is working perfectly

I have many Process variables that need to be shared and so I use the Microsoft Imuutable Dictionary in my singleton store and subscribe to the Action used to update the same store in each process

All Blazor users have identical access to the store also.

I know it is quirky it is my first Blazor Server project targeted at an embedded Debian Amplicon Impact PC.

From: Peter Morris @.> Sent: 08 January 2023 18:56 To: mrpmorris/Fluxor @.> Cc: nthompson0033 @.>; Author @.> Subject: Re: [mrpmorris/Fluxor] Subscribe to Action in ASP.NET Blazor server (Issue #396)

External Email

Fluxor is thread safe, but I don't think it would be a very effective way of having multiple users share a single state.

In answer to your question, you can call IStore.InitializeAsync() when your server starts.

- Reply to this email directly, view it on GitHubhttps://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmrpmorris%2FFluxor%2Fissues%2F396%23issuecomment-1374903075&data=05%7C01%7C%7C00bde5d90b3347dbcae608daf1aa07a1%7C441b7b2c0b8443f99ed858339f0206e5%7C0%7C0%7C638088009833099250%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=d%2BYOhPqs6LAinPSFaxrOoUjX8Jt48d%2BYTpoDTJhSUcY%3D&reserved=0, or unsubscribehttps://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FABYWINOOM4PO7ZMT4PPXREDWRMEVBANCNFSM6AAAAAATTTTSCE&data=05%7C01%7C%7C00bde5d90b3347dbcae608daf1aa07a1%7C441b7b2c0b8443f99ed858339f0206e5%7C0%7C0%7C638088009833099250%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=3GhSYoyTkdjFaD3k8N0p3st6VryN%2FWWz1DeXQwP3gmM%3D&reserved=0. You are receiving this because you authored the thread.Message ID: @.**@.>>