Search code examples
javascriptangularjslocalforage

Is there any way to find out if localForage/indexedDb is processing data?


So I have this webapp, and I am using the async localForage (angular localForage to be specific). Now, I want to warn the user if he tries to close the browser window while there are still some localForage operations going on.

I know at least the browser knows, because in Firefox if I do close the window, it gives me a warning (albeit after I open a window again) that some indexedDb operations were cancelled (localForage uses indexedDb).


Solution

  • Nothing similar to that is available, but you can wrap localForage with a custom service that

    1. sets a special flag once an operation with localForage is initiated
    2. releases the flag in the callback (once the operation is completed)