-
Notifications
You must be signed in to change notification settings - Fork 98
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
Importing into react-native without using web worker still causing error #319
Comments
I see I can pass in my own worker? Would passing in something like this work |
Update: Seems it IS just the worker! Which is good news I think.
If you do this the mobile app stops erroring. So I think it's really just that fake worker has something off about it triggering the error. So if I can just use a different worker I think it'll work fine in react native. |
@soerendomroes I didn't actually get this working yet unfortunately. The above example code stops breaking the mobile app but it doesn't actually work. Whenever I get the postMessage it's just the graph data I passed into elk, not the processed data. |
Are there any examples of a custom worker anywhere? The "FakeWorker" in the source code has the Dispatcher dependency. I don't have access to that and given the postMessage isn't "posting" the compiled layout code it makes me think I need that dispatcher to work properly. |
I modified the exportLayout to this
And now it's working on mobile. I copied the elkworker file and made those changes to the export layout function. and used it like this
I haven't tested to see if this breaks actual web workers (probably does) but this at least makes elk usable on react-native. |
Sadly, I almost never use elkjs. Hence, I am a little unfamiliar with this. Please, update this issue if you think that this is the appropriate solution or if this does not work. |
@soerendomroes Do you happen to know where in the source code this FakeWorker is created? I might take a stab at submitting a proper PR to make the Worker more generic and exposing the Dispatcher. This would make the "bring your own worker" actually work (assuming I haven't done something wrong and this is all way overly complicated lol) So I don't know that I would mark this as "answered" but the above is definitely working for me. |
It should be in here. https://github.com/kieler/elkjs/blob/master/src%2Fjs%2Felk-api.js |
The modifications I made were to the root elk-worker.js file. My understanding is that's the generated file from the GWT (java transpiler?) https://github.com/kieler/elkjs/blob/master/src/java/org/eclipse/elk/js/ElkJs.java Here? The section I modified to make it work is commented out in that file though. |
Describe the bug
I have this library working perfectly on web and realized I needed to check it on our mobile app (we share the layout code in a monorepo) and unfortunately I hit a snag :( I'm not using web workers so I don't think that's the issue. Was hoping you could point me in the right direction. Hopefully it's something simple like I just need a shim or wrapper for the bundled code to make it happy in react-native.
It doesn't seem like there's anything in the code that wouldn't be inherently incompatible with react-native. So I suspect it might just be a bundle issue and I just need to apply a wrapper of some sort. But some insight on potential issues would be greatly appreciated.
Screenshots
ELK Version
0.9.3
The text was updated successfully, but these errors were encountered: