spierala/mini-rx-store

use of mini-rx-store within a shared worker

Closed this issue · 8 comments

h4de5 commented

We are trying to use the store within a shared worker in such a setup there is no "window" object, like it is used in some places:

it would be great to have a parameter to use self in such places or get any other hints on how to implement such a plan

Do you have issues only with the DevTools? What if you remove the extension?

Do you see a specific error?

Thinking about a fix like this one:
jonoward/ng2-redux@5ecc43e

h4de5 commented

Yes it seems to be only there. How do I remove the extension?

I only have this configuration:

const store: Store = configureStore({
  extensions: [
    new ImmutableStateExtension()
  ]
});

it is still bundled and executed somehow.

Which bundler are you using? Webpack, Rollup or something else? Which framework if any?

I tried once with Angular/Webpack and the extensions where not part of the bundle. But they where part of the bundle in Svelte/Rollup. That is still on my todo list :)

Can you in the meantime try to define the window object before any MiniRx code is running to prevent any exceptions?

Something like that:

const window = window ? window : {}

h4de5 commented

I am using angular + webpack + nx.
the shared worker which uses this store is part of typescript nx library within that workspace.
the context of the shared worker does not have a window object. initializing it before does not work either.
I am not sure what I can provide to the help you analyse the problem :(

I do not understand how code from the extension class can be executed without writing new Extension().
Are you very sure that the extension is not instantiated somewhere in the application code?

There are some things which could help us to analyze further:

  • provide a stacktrace of the error
  • is it a compile or runtime error?
  • can you provide a repo with a minimalistic reproduction of the error?
  • why are you using shared worker? Maybe there is an alternative approach possible?
  • which version of MiniRx are you using? You could try mini-rx-store@4 beta, but I have only little hope that it would fix the issue

Hey @h4de5,

there was recently a similar issue regarding the undefined window object: #124

It is fixed in the latest mini-rx-store@beta

h4de5 commented

i have read this as well. i have not got the time to test it, or provide more information as you requested. sorry :/

No problem.

In the meantime I will close the issue.

Feel free to reopen this issue if you still encounter the problem.