-
-
Notifications
You must be signed in to change notification settings - Fork 149
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
Remove the dependencies on the UI of js backend files #813
Comments
It should be possible to do that by adding an error callback to the functions (just like we have callbacks to return the results) Another option would be to change the code to use Promises instead: we had thought about it in #67, but I don't think it's worth it. It would be a much more significant change for a code that will (hopefully) become deprecated when we manage to use wasm lbzim instead. |
I see the issue, especially with regard to a WASM/ASM backend which does indeed run in a worker and is isolated from UI completely. Thanks for the explanation. |
Since my current PR is almost complete, I would like to take this up. |
Now that we have merged #804 (and several other ones), you can tackle this one and #841
Ideally, we should remove them from xzdec_wrapper.js and zstddec_wrapper.js too. But it's certainly more complicated. In the end, we shoud be able to remove the uiUtil parameters in the following lines at the beginning of each of these files:
To be able to do that, we have to remove the calls to For zimArchive*.js, a clean solution should be to add a parameter For settingsStore.js, it will be a bit different. I think we should remove the @Jaifroid, don't hesitate to say if you disagree or have better solutions |
Regarding *dec_wrapper.js, here is a possible solution: In app.js, we could add some code that runs on startup, and reads the *MachineType of each wrapper. If it's null, it should try again one second later (with a |
Sounds good to me, though I had to look up "lambda function" (today I learnt...). I'd just add (I didn't check code) that where there is an error being reported inside the catch of a Promise, then the Promise will pass that error to the catch function of the calling function (which might need to be added if there isn't one). In such cases it should be easy, but I don't know from memory if there are many such cases. It might be easier to break this into a couple of PRs, one with easy cases, and another with the more complicated ones (like the wrappers), which we can collaborate on. |
That's maybe not necessary. We only need to show the decompressor type in the API panel when the user clicks on Config. And if it's not ready on startup when Config is first shown, then we can simply show "Decompressor not initialized" (which currently shows in a number of cases anyway). Thereafter, the object |
@mossroy By this, do you mean an anonymous function? Because being on ES5 we can't use arrow functions I suppose. |
Also, the Will that work fine? |
You're probably right, and it would indeed be much simpler. |
You're totally right. I meant an anonymous fonction. My bad |
It should. You will have to add the |
…e-UI-of-JS-backend-files-#813 Remove-the-dependencies-on-the-UI-of-JS-backend-files-#813
I reopen this, because there are still the *dec_wrapper.js to handle |
I am going to work on this task. If you have attempted to solve this issue before, I would appreciate it if you could share what you have done so far. It would help me as a beginner in this project. |
@gaurava05 You can see what was previously tried in #1273, but that PR got stuck with failing tests and never got completed. As a beginner, please read CONTRIBUTING.md carefully (in root of Repo) all the way through, in particular what it says about setup and testing. |
In fact, @gaurava05, this is an issue you previously worked on, and largely solved with the exception of one file! So please look back at your previous work in the history above! |
Hey @BirushaNdegeya, you can find all my work and discussions in the PR #845. Please have a look. |
@gaurava05 Thanks! |
In zimArchive and zimArchiveLoader files, there are error cases where we display an error message to the user.
It was initially done using
window.alert
, and is now done usinguiUtil.systemAlert
.In all cases, a backend js file should not depend on the UI: it breaks the software layers.
For example, this code might one day run inside a Worker, where it would not have access to the UI at all, and this would simply fail.
The error should instead be returned to the caller, that would have the responsibility to handle it: maybe display it to the user, or something else
The text was updated successfully, but these errors were encountered: