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

Store atom state in context #190

Closed
wants to merge 5 commits into from
Closed

Conversation

TrySound
Copy link
Contributor

@TrySound TrySound commented May 9, 2023

Ref #171

Here's initial attempt to move all stores state into global context object. Context is basically a listeners queue and a map of stores states.

Context management api is still yet to explore. For now it's for internal usage now.
The important thing here is accessing context with getter function which can allow to use AsyncLocalStorage in node and cloudflare workers.

TrySound and others added 5 commits April 17, 2023 17:44
* Check referential equality before notifying

React useSyncExternalStore triggers rerenders only when value
is not referentially equal to previous one.

Here updated atom to not notify subscriptions when new value is same.

This change will let as avoid additional checks in user land
and rely more on store.subscribe in non-react logic.

* Remove packageManager
* Avoid copying listeners

Found the source of change here nanostores@242d2b1

Though back then listeners were called in the same loop.
Now listeners are called when iterating over listenerQueue which makes
copying unnecessary.

* Latest node is putting byte here for some reason
`store.notify()` was used to enforce update when no value is changed
though this case is not valid in react which checks referential equality
before update.

Here remove store.notify from types andd dropped notifyId which was
used to enforce recomputing of dependent computed stores.
Ref nanostores#171

Here's initial attempt to move all stores state into global context
object. Context is basically a listeners queue and a map of stores
states.

Context management api is still yet to explore. For now it's for
internal usage now.
@ai
Copy link
Member

ai commented May 10, 2023

Thanks. I plan to review it when I will come back from China, on next week.

@ai
Copy link
Member

ai commented May 20, 2023

At first glance it looks solid for me. But I am afraid to release it in 0.9 and will release your previous PRs first.

@TrySound
Copy link
Contributor Author

Sure, sounds fine

@ai ai deleted the branch nanostores:next May 24, 2023 18:58
@ai ai closed this May 24, 2023
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.

None yet

2 participants