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

Extend a signal API to match the Svelte store contract #95

Closed
kolodziejczak-sz opened this issue Sep 7, 2022 · 1 comment
Closed

Extend a signal API to match the Svelte store contract #95

kolodziejczak-sz opened this issue Sep 7, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@kolodziejczak-sz
Copy link

kolodziejczak-sz commented Sep 7, 2022

First of all, thank you for the library!

I'd like to suggest a proposal to extend the usage of the signals-core library to the Svelte framework.
I mean an implementation of a Svelte's store contract, which is about a subscribe method: 

type Subscriber<T> = (value: T) => void;
type Unsubscriber = () => void;
subscribe(run: Subscriber): Unsubscriber;

So, the signals would need to have an additional subscribe method that returns a function that lets you unsubscribe.
The Nanostore library does exactly that: https://github.com/nanostores/nanostores#svelte, so developers can use atoms without any dedicated adapter.
I'm sure the advantages of the ability to subscribe to a certain signal would exceed the Svelte support.

More info about Svelte's stores can be found here:
https://svelte.dev/docs#run-time-svelte-store
https://github.com/sveltejs/svelte/blob/master/src/runtime/store/index.ts

Thanks

@kolodziejczak-sz kolodziejczak-sz changed the title Extend a signal API to match a svelte store contract Extend a signal API to match the Svelte store contract Sep 7, 2022
@marvinhagemeister marvinhagemeister added the enhancement New feature or request label Sep 8, 2022
@marvinhagemeister
Copy link
Member

@kolodziejczak-sz this is a great idea! Went ahead and implemented that in #134 . Signals can be used natively with Svelte with the latest version 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants