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

Typescript namespace store binding with $ #8046

Closed
danbord opened this issue Nov 21, 2022 · 4 comments
Closed

Typescript namespace store binding with $ #8046

danbord opened this issue Nov 21, 2022 · 4 comments

Comments

@danbord
Copy link

danbord commented Nov 21, 2022

Describe the problem

I'd like to organize my store better by wrapping my store files in namespaces.

But there is no way to use Autosubscription when a store is namespaced.

example:

user-store.ts

export namespace UserStore{
   export username = writable<string>("user1");
}

user.svelte

<div>{$UserStore.username}</div>

Describe the proposed solution

I'd like to be able to autosubscribe to namespaced stores like this:

{$UserStore.username}

Alternatives considered

an alternative could be:

{UserStore.$username}
or
{$(UserStore.username)}

Importance

would make my life easier

@JeanJPNM
Copy link

Right now svelte only supports stores that are top level variables like this:

const { username } = UserStore

$username

UserStore.$username generally implies that the UserStore namespace contains a member named $username

@Conduitry
Copy link
Member

There's #4079 for supporting subscribing to stores that aren't top-level variables.

I'm not sure whether there's anything else here, or how the TypeScript namespace part affects anything.

@dummdidumm
Copy link
Member

namespaces are a deprecated feature of TypeScript, so it's highly unlikely we would ever support something like this. I guess the JS-version of this would be

export const UserStore = {
  username: writable("foo")
};

... which means you want to subscribe to nested stores, and I think there's an issue for that somewhere in this repo.

@Conduitry
Copy link
Member

Yup, I linked to the issue for subscribing to that in my previous comment. I'll close this if we're not going to be supporting anything namespace-specific.

@Conduitry Conduitry closed this as not planned Won't fix, can't repro, duplicate, stale Nov 21, 2022
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

No branches or pull requests

4 participants