Skip to content

Updating state in a promise is not working? #11413

Answered by paoloricciuti
intzaaa asked this question in Q&A
Discussion options

You must be logged in to vote

Tbf it feels strange that this

store.directory = await LocalFileSystemAdapter(store.localDirectory);

is working. To cross module/function boundaries you need getters and setters.

// store.svelte.ts
import { UniversalDirectory } from './filesystem.svelte';

let localDirectory: FileSystemDirectoryHandle = $state();
let directory: UniversalDirectory = $state();

export const store = {
	get localDirectory(){
                return localDirectory;
        },
	set localDirectory(ld){
                localDirectory = ld;
        },
	get directory(){
                return directory;
        },
	set directory(d){
                directory = d;
        },
};

Alternatively if you are ok with only m…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@intzaaa
Comment options

Answer selected by intzaaa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants