Really cool approach to solving the common pain points in React state management — love how Nucleux avoids provider nesting and unnecessary re-renders! Curious though, how does Nucleux handle deeply nested components or cross-store communication at scale?
Nucleux
0 Comments
Thanks Andrew! Great questions about scalability.
For deeply nested components, Nucleux shines because there's no provider hierarchy to manage - you can access any store from any component at any depth using the same hooks. No need to thread context through multiple levels.
For cross-store communication, we have built-in dependency injection:
class NotificationStore extends Store {
userStore = this.inject(UserStore)
notifications = this.atom([])
constructor() {
super()
// Auto-react to user changes
this.watchAtom(this.userStore.currentUser, (user) => {
if (user) this.loadNotifications(user.id)
})
}
}
The IoC container handles the relationships automatically, so stores can depend on each other without circular dependency issues. Stores are lazily instantiated and cached as singletons, so you get predictable initialization order and memory efficiency even with complex dependency graphs.
We've tested this pattern in production apps with 20+ stores and it scales really well.
Would love to hear your thoughts if you give it a try!