Easy way to determine any beforeunload callbacks do you need.
Install with yarn:
yarn add good-goodbye
# or npm:
npm i -S good-goodbye
import GooodGoodbye from 'good-goodbye'
GooodGoodbye.set("testUnload", () => {
SomeModule.call("unloadCallback")
})
//To show browser prompt return text or true value
GooodGoodbye.set("testUnload", () => {
SomeModule.call("unloadCallback")
if (SomeModule.hasWarnings()) return "Warning"
if (SomeModule.unfinished()) return true
})
//Get all callbacks
GooodGoodbye.callbacks // => { testUnload: f }
//Unset callback
GooodGoodbye.unset("testUnload")
//Unset all callbacks
GooodGoodbye.unsetAll()
Released under MIT License.
Created by spaceIess.