javascript - How Can I Reliably Complete Asynchronous Operations on Firefox browser close? -
i'm writing browser extension firefox uses indexeddb save local data. when browser closes, i'd write latest data out indexeddb. however, indexeddb entirely asynchronous, , appears firefox closes before asynchronous writes complete. (i can see database file being created , journaling file getting discarded when browser closes.) there way reliably complete asynchronous operations when firefox closing?
you use eventlistener (you may have write database) listen window close event , preventdefault until finish storing things , close window on callback.
window.addeventlistener("close", function(e) { e.preventdefault(); //save things //call window.close on callback window.close(); }, false); there's different question on stackoverflow may have better way listen application close instead of window close. process similar.
Comments
Post a Comment