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

Signals proxy #10

Merged
merged 10 commits into from
Oct 31, 2023
Merged

Signals proxy #10

merged 10 commits into from
Oct 31, 2023

Conversation

dy
Copy link
Owner

@dy dy commented Oct 27, 2023

This changes store to comprise signals, rather than own pubsub.
Also streamlines / cleans code & fixes some non-obvious bugs.
Fixes #9 and addresses #8.

@dy
Copy link
Owner Author

dy commented Oct 27, 2023

@aelbore this PR introduces signals-proxy store. It seems to be a bit less efficient than either just signals or proxy store in terms of performance (negligibly though). Also it adds some extra 2kb, since @preact/signals-core is included. But it is more resilient and supports signals as values.
I wonder what's the way you're anticipating to connect your store to sprae - I'd give it a try before merging to make sure new release is meaningful. Otherwise I'd keep just proxy-based store, since it's minimal, self-isolated and most efficient. You can connect any signals to sprae as

let state = sprae(element, {greeting: 'Huh?'})
let s1 = signal('Hello')
fx(() => state.greeting = s1)

@aelbore
Copy link

aelbore commented Oct 29, 2023

@aelbore this PR introduces signals-proxy store. It seems to be a bit less efficient than either just signals or proxy store in terms of performance (negligibly though). Also it adds some extra 2kb, since @preact/signals-core is included. But it is more resilient and supports signals as values. I wonder what's the way you're anticipating to connect your store to sprae - I'd give it a try before merging to make sure new release is meaningful. Otherwise I'd keep just proxy-based store, since it's minimal, self-isolated and most efficient. You can connect any signals to sprae as

let state = sprae(element, {greeting: 'Huh?'})
let s1 = signal('Hello')
fx(() => state.greeting = s1)

Hey thanks for this, but actually I just want to reuse my signal store so that I don't want to rewrite it again, logics in the it a bit a lot so no time to rewrite it

if this compromise your library and no performance benefits, I can just Create small adapter or utility to bridge my existing store to state of sprae.

I understand correctly fx is an effect of sprae state?

@dy dy merged commit 4987e07 into main Oct 31, 2023
@dy dy deleted the signals-proxy branch November 9, 2023 00:14
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.

use signals as state management
2 participants