Ported useStore from Fable.LitStore#15
Open
JordanMarr wants to merge 1 commit intofable-compiler:mainfrom
Open
Ported useStore from Fable.LitStore#15JordanMarr wants to merge 1 commit intofable-compiler:mainfrom
useStore from Fable.LitStore#15JordanMarr wants to merge 1 commit intofable-compiler:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi Alfonso!
I have been doing some updates to my (now 4 year-old!) Fable client project, including recently updating to Fable 4.
What an enjoyable project it has been! Thank you again for all you have done with Fable.
Anyways, I wanted to refactor my usage of
React.useContextto use a full-fledged shared/global Elmish loop, similar to what I can do with Fable.LitStore, but using Fable.ReactStore. (See this discussion on Twitter for more context.)The closest function I could find in the Fable.ReactStore package was
useStoreLazy, but it was problematic in that it would not always refresh changes to the store from one component into another. I finally came to the conclusion that maybeuseStoreLazywas meant for a more specific use case than what I needed.So, I ended up porting my original port of
useStorethat became Fable.LitStore into Fable.ReactStore. This does exactly what I need and allows me to phase outReact.useContextin my application.(One other thing: I wasn't sure if there is a better way to share a global Elmish loop via the new Fable.React
React.useElmishin Fable 4, but I didn't see a way to do it.)Example
Global/Shared Elmish Loop
Sharing context in components