Closed JSn1nj4 closed 4 months ago
set
hash
isDirty
unset
isClean
beforeunload
receive
function reportDirty(hashVal, isDirty) { dispatchEvent(new CustomEvent('reportDirtyState', {detail: {hashVal, isDirty}}) } function checkDirty(hashVal, emitBack) { dispatchEvent(new CustomEvent('checkDirtyState', {detail: {hashVal, emitBack}}) } function receiver({detail: {isDirty}}) { console.info(`isDirty: ${isDirty}`) // some kind of usage here } function forgetDirty(hashVal) { dispatchEvent(new CustomEvent('forgetDirtyState', {detail: {hashVal}})) } let receiveEvent = 'reporter:receive' window.addEventListener(receiveEvent, receiver)
Fixes #156
Not happening
Starting use cases
Implementation
set
method:hash
(string),isDirty
(boolean)unset
method:hash
isClean
property that reports overall dirtiness or cleanliness of statebeforeunload
and any other selected eventsisClean
receive
event defined by the reporterreceive
method for listening for the above event and acting accordinglySample reporter implementation
Fixes #156