Skip to content

Clearing a SourceList? #48

Answered by JordanMarr
houstonhaynes asked this question in Q&A
Jan 13, 2024 · 4 comments · 11 replies
Discussion options

You must be logged in to vote

There are a bunch of ways you could call the ClearChat() method from the MainViewModel.
The easiest way would probably be to just do this:

    member this.ClearChatCommand() =
        let chatView = this.ChatView :> StyledElement
        let chatVM = chatView.DataContext :?> ChatViewModel
        chatVM.ClearChat()

There is no real value to be gained by pushing that into the local Elmish loop, so better to just delete the ClearChatCommand message in your MainViewModule and call the ChatViewModel directly from your MainViewModel.

Another way to do it would be to move your chat messages into the App module as global app state. But it's not worth breaking up the modularity you have just to f…

Replies: 4 comments 11 replies

Comment options

You must be logged in to vote
9 replies
@JordanMarr
Comment options

@houstonhaynes
Comment options

@JordanMarr
Comment options

@houstonhaynes
Comment options

@houstonhaynes
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@houstonhaynes
Comment options

Comment options

You must be logged in to vote
1 reply
@houstonhaynes
Comment options

Answer selected by houstonhaynes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants