-
#83
4a1fea9Thanks @Wendystraite! - Addparentproperty tocreateInjector. This property enables hierarchical dependency injection by allowing child injectors to inherit and override dependencies from parent injectors. This creates a tree-like structure where:- Child injectors can access and use the dependencies of their parent injectors.
- Dependencies can be overridden at the child injector level, allowing for more granular control over dependency resolution.
Add
MoleculeProviderfor React applications. This React component provides the implementation of a molecule interface for all molecules lower down in the React component tree. It uses the new parent-child injector hierarchy to ensure that existing molecule instances are preserved while allowing interface resolution.
-
#85
0dbe0f6Thanks @Wendystraite! - Fix typescript inference of generics molecules. -
#88
259c83dThanks @Wendystraite! - Fix global molecules not garbage collected if another global molecule is used.
- #59
58ccacfThanks @loganvolkers! - Improve handling for molecules that throw exceptions. This will no longer break the globalusefunctions, or breakgetMolorgetScope. Fixes #61
2.1.4 - 2024-03-06
Small fixes for browser compatibility.
- #52 - remove toSorted usage because of browser compatibility. Thanks @andrewdoro
2.1.3 - 2024-02-16
Fixes reactivity in the React ScopeProvider
- #50 - Fix the internals of
ScopeProviderso that it is reactive. Thanks @OhSeungWan
2.1.2 - 2024-02-14
Minor release to fix bug in Firefox
- #48 - Fix the internals of Bunshi to not rely on
Symbolas aWeakSetkey. Fixes firefox. - thanks @alexlag
2.1.1 - 2024-02-07
Minor release to fix bug in react useMolecule
- (React)
useMolecule- When molecule returns a function, useMolecule should also return the same function #47 - thanks @3846masa
2.1.0 - 2024-01-22
Version 2.1.0 is a big update to Bunshi. It fixes a few key efficiency issues in #35 and #39. It introduces
the new use syntax for wiring up dependencies, and the new onMount and onUnmount lifecycle events
for cleaning up dependencies, even when the state management libraries themselves don't have it.
In the process of preparing this release, the number of test cases was expanded dramatically to make sure that the lifecycle of bunshi molecules remains stable and predictable going forwards. Some behaviour that was implicit is now being explicitly tested for.
Big thank you to the community for the help.
- @davidisaaclee for highlighting the issue of molecules being run too frequently in #39
- @asfktz for playing with XState and promoting the creation of cleanup lifecycle in #35. Thanks @Andarist for the pointers.
- @00salmon for providing feedback on the release candidates
- Change to scoping. Object scopes will now be cleaned up, even for non-overlapping leases.
- Molecules callbacks are called more efficiently. Reduces the number of calls in many cases. Fixes #39. Thanks @davidisaaclee
onMountandonUnmountlifecycle hooks inside of molecules. Fixes #35. Thanks @asfktz- Support for React strict mode (and tests). Fixes #35
- New
usesyntax for depending on scopes or molecules, - Add methods to injector and scope for using lazily to support React strict mode
2.1.0-rc.2 - 2024-01-08
- Add methods to injector and scope for using lazily to support React strict mode
- Removed support for conditional dependencies. When detected, conditional dependencies will now throw an error.
- Removed
subscriptionIdfrom all calls (introduced in 2.1.0-rc.1)
2.1.0-rc.1 - 2023-11-23
- Change to scoping. Object scopes will now be cleaned up, even for non-overlapping leases.
- Molecules callbacks are called more efficiently. Reduces the number of calls in many cases. Fixes #39
- Injectors have new methods to pass along a
subscriptionIdto ensure that default scopes can be used and cleaned up.
onMountandonUnmountlifecycle hooks inside of molecules. Fixes #35- New
usesyntax for depending on scopes or molecules
2.0.2 - 2023-11-01
- Changed bundling to support splits in common JS. Fixes #29
2.0.1 - 2023-09-21
- Added
typesVersionsinpackage.jsonto support older typescript versions
2.0.0 - 2023-09-20
Bunshi 2.0 is the next big release of jotai-molecules. We were working on adding vue support, and in the process realized that not only did
we not rely on any code from jotai, but also that the concept of dependency injection for the frontend that we were working on was actually
useful for a number of different tools and libraries.
For vue we realized that molecules are a useful way of sharing and scoping a ref across an application. This is similar to the goals of pinia,
but we could accomplish it in a more granular way without relying on strings keys.
We also saw that other tools like valtio suffer from the need for memoization. Valtio recommends using useRef for keeping a stable proxy scoped to
a component or a component tree.
So, instead of creating vue-molecules and valtio-molecules and others, we decided to keep it simple and rename our library.
The new name for jotai-molecules is Bunshi. bunshi (分子, ぶんし) is the japanese word for molecule. Why bunshi? We are big fans of valtio, zustand and jotai,
so we wanted to keep with the tradition of naming libraries using other languages. If you didn't now, zustand is German for "state" and valtio is Finnish for "state".
The other thing that is releasing at the same time here is our new documentation website. It's difficult to keep everything up to date in a single Readme, so we moved to a static site generator.
Moving for jotai-molecules to bunshi? To migrate change your imports from jotai-molecules to bunshi/react for example:
- import { useMolecule, molecule } from "jotai-molecules"
+ import { useMolecule, molecule } from "bunshi/react"- Renamed from
jotai-moleculestobunshi - Default export no longer returns react. Users will need to change imports from
jotai-moleculestobunshi/react
bunshiVanilla JS supportbunshi/vueVue supportbunshi/reactReact-specific importcreateInjectorandgetDefaultInjectorto access internal statemoleculeInterfacefor creating bindable interfacesComponentScopefor pushing state down into components- Documentation website
1.1.1 - 2023-04-20
- Updated license copyright to be in line with SaaSquatch open-source policy.
1.1.0 - 2022-05-31
- Added options for overriding scope in
useMolecule. This removes the need forScopeProviderin a number of cases.
1.0.3 - 2022-04-08
- Improve performance when using thousands of molecules
1.0.2 - 2022-04-08
- Fix bug with
ScopeProviderwhere primitive values would not be cached - Add
displayNameto molecule and scope
1.0.1 - 2022-04-07
- Fix bug with
ScopeProviderwith nested scopes being undefined
1.0.0 - 2022-03-31
Initial release of jotai-molecules
moleculefor creating a molecule or dependent moleculeuseMoleculea React hook for using a moleculecreateScopefor creating a scope for moleculesScopeProvidera React component for providing scope to the tree