You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Given that you have LibraryMolecule that is relying on ConfigScope to set up how the molecule should be used:
import{Atom,atom}from"jotai";import{molecule,createScope,Molecule,use}from"../../vanilla";exporttypeExampleConfig={example: Atom<string>;};exportconstConfigScope=createScope<Molecule<ExampleConfig>|undefined>(undefined,);exportconstLibaryMolecule=molecule(()=>{constconfigMol=use(ConfigScope);if(!configMol)thrownewError("This molecule requires ConfigScope to function!");constconfig=use(configMol)asExampleConfig;constderivedAtom=atom((get)=>get(config.example).toUpperCase());return{
...config,
derivedAtom,};});
And you have two different configs for scope:
exportconstConfigAMolecule=molecule<ExampleConfig>(()=>{return{example: atom("Config A"),};});constScopeB=createScope("Longer tree");exportconstConfigBMolecule=molecule<ExampleConfig>(()=>{// This creates a different path for the dependencies of `LibraryMolecule`// And can throw errorsuse(ScopeB);return{example: atom("Config B"),};});
When you use LibraryMolecule with ConfigScope set to ConfigAMolecule
Then it works just fine
But you use LibraryMolecule with ConfigScope set to ConfigBMolecule
And it will throw a Molecule is using conditional dependencies. This is not supported. exception
This is a new limitation in Bunshi 2.1 as part of the introduction of molecule lifecycles.
The text was updated successfully, but these errors were encountered:
Conditional dependencies started throwing error in Bunshi 2.1 with the introduction of lifecycle hooks because it became difficult to know how to unmount dependencies when a scope was released.
The un-intended side-effect of that was disabling this use-case.
Given that you have
LibraryMolecule
that is relying onConfigScope
to set up how the molecule should be used:And you have two different configs for scope:
When you use
LibraryMolecule
withConfigScope
set toConfigAMolecule
Then it works just fine
But you use
LibraryMolecule
withConfigScope
set toConfigBMolecule
And it will throw a
Molecule is using conditional dependencies. This is not supported.
exceptionThis is a new limitation in Bunshi 2.1 as part of the introduction of molecule lifecycles.
The text was updated successfully, but these errors were encountered: