Skip to content

Is there a best way to mount local storage from Web Worker? #107

Answered by james-pre
atty303 asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @atty303!

Is there a good way to reference localStorage in such a case?

I would recommend using the Port backend if you are using a web worker.

I created SimpleAsyncStore based on SimpleSyncStore.

This is really cool! I'm actually reworking the system of stores right now to use a single. unified Store class, with async mirroring.

And it is mounted ...

I recommend you inline the config, since it can be easier to understand and eliminates otherwise used variables.

For your use case:

const rootZip = await fetch(`${assetPrefix}/root.zip`);

await zenfs.configure({
	mounts: {
		'/root': {
			backend: Zip,
			zipData: await rootZip.arrayBuffer(),
			name: 'root.zip',
		},
		'/user': {
			

Replies: 0 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@atty303
Comment options

@james-pre
Comment options

Answer selected by atty303
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