How to intercept window close event while having access to the Storage class #187
Closed
mikailcf
started this conversation in
Anytype apps
Replies: 1 comment
-
For future reference: I ended up using events to be able to trigger the local storage update from a window event. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm currently in the middle of implementing a feature where I ideally should be able to receive a window will close event in a context where I have access to the
Storage
class to update a value in the local storage, which I wasn't able to do. I'm gonna elaborate a bit more below on my progress, but any pointers would be great.I've never worked in an Electron app before so I don't know if I'm missing something basic. A few of my findings so far:
BrowserWindow
'son('closed', ...)
method of intercepting, which could be done inwindow.js
. The problem here is that I don't seem to be able to accessStorage
there. It seems like thewindow.js
code is some kind of "framework code" and theStorage
class is some kind of "app code", with no easy way of one requiring/importing/calling the other. (I think there's also the option of just updating the local storage directly in there, which I haven't tested and I'm trying to avoid, to keep the responsibility of updating it throughStorage
).window.require('electron')
in the code that has access toStorage
, but I get awindow.require is not a function
error.window.js
to store callbacks and call that function somewhere where I have access toStorage
, but like in the first point I wasn't able to requirewindow.js
.I have the feeling that there's a more fundamental/architectural concept I'm not grasping here. Again any help would be appreciated!
Beta Was this translation helpful? Give feedback.
All reactions