[WIP] Refactor to use the new jotai store derive method (Attempt 2) #56
+15,471
−53
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.
Summary of changes
Update ScopeProvider to use the new
unstable_derive
api on store (pmndrs/jotai#2652).The new code is much simpler and should address #25 and #36.
Changes
Resolves #25 and #36.
store
prop added to ScopeProvider props.The scoped store will use the internals of this store if provided.
Tests Results
01_basic_spec
✅ 01. ScopeProvider does not provide isolation for unscoped primitive atoms
✅ 02. unscoped derived atoms are unaffected in ScopeProvider
✅ 03. ScopeProvider provides isolation for scoped primitive atoms
❌ 04. unscoped derived can read and write to scoped primitive atoms
❌ 05. unscoped derived can read both scoped and unscoped atoms
❌ 06. dependencies of scoped derived are implicitly scoped
❌ 07. scoped derived atoms can share implicitly scoped dependencies
✅ 08. nested scopes provide isolation for primitive atoms at every level
❌ 09. unscoped derived atoms in nested scoped can read and write to scoped primitive atoms at every level
❌ 10. inherited scoped derived atoms can read and write to scoped primitive atoms at every nested level
02_removeScope
✅ atom get correct value when ScopeProvider is added/removed
03_nested
✅ nested primitive atoms are correctly scoped
04_derived
❌ parent scope's derived atom is prior to nested scope's scoped base
05_derived_self
❌ derived dep scope is preserved in self reference
06_implicit_parent
✅ level 1: "BD" and level 2: "BD"
✅ level 1: "BD" and level 2: "DB"
✅ level 1: "DB" and level 2: "BD"
✅ level 1: "DB" and level 2: "DB"
07_writable
✅ "writableAtom" updates its value in both scoped and unscoped and read scoped atom (27 ms)
✅ "thisWritableAtom" updates its value in both scoped and unscoped and read scoped atom (5 ms)