fsbolero / Bolero

Bolero brings Blazor to F# developers with an easy to use Model-View-Update architecture, HTML combinators, hot reloaded templates, type-safe endpoints, advanced routing and remoting capabilities, and more.
https://fsbolero.io
Apache License 2.0
1.06k stars 54 forks source link

Q: Initiate a message from server to client(s) #200

Open KingKnecht opened 3 years ago

KingKnecht commented 3 years ago

I'm trying to figure out how I could send messages from the server to clients. I have searched the issues here and found some topics about SignalR, but I have no idea how to do that nor if it is possible at all at the moment.

My example is the book list from the template. I can remove a book by its ISBN and I want other clients to have the modified list of books in sync.

There is BookService with following function:

removeBookByIsbn = ctx.Authorize <| fun isbn -> async {
    books.RemoveAll(fun b -> b.isbn = isbn) |> ignore
    //How to inform clients that the list has changed?
}

Thx

JaggerJo commented 3 years ago

Hi @KingKnecht,

take a look at this sample - it shows how to properly setup a SignalR Hub for broadcasting.

https://docs.microsoft.com/en-us/azure/azure-signalr/signalr-tutorial-build-blazor-server-chat-app

srid commented 3 years ago

Is there a Bolero project template that uses SignalR for real-time communication (not just one-way broadcast) between server and client rather than XHR requests?