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

Added defaultEqualityCheck to createFacet, and introduced createStaticFacet #87

Merged
merged 9 commits into from
Aug 31, 2022

Conversation

Shenato
Copy link
Contributor

@Shenato Shenato commented Aug 25, 2022

This PR does two things

  • Changes the default behaviour for createFacet to not update without doing a defaultEqualityCheck
  • Introduces createStaticFacet function to create initial facets outside the react context that are meant to be replaced later by real facet in the react context. Such valid use-case is for example with createContext like so
const myFancyContext = createContext<Facet<number | undefined>>(createStaticFacet(undefined))
export const useMyFancyContext = () => useContext(myFancyContext)

Now your context facet is completely static, not writable and if by accident you manage to observe it won't register any listeners and will give you a warning in production.

@Shenato Shenato requested a review from pirelenito August 25, 2022 15:06
@Shenato Shenato requested a review from pirelenito August 29, 2022 09:48
Copy link
Member

@pirelenito pirelenito left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing job with the unit tests! ❤️👏

@Shenato Shenato merged commit 0bd23d7 into main Aug 31, 2022
@Shenato Shenato deleted the create-fake-facet branch August 31, 2022 09:17
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.

2 participants