-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5aeb2b9
commit 1e711f4
Showing
2 changed files
with
29 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
let updateAvailable = false; | ||
const updateAvailableCallbacks = []; | ||
export const onUpdateAvailable = (callback) => { | ||
if (updateAvailable) callback(updateAvailable); | ||
else updateAvailableCallbacks.push(callback); | ||
}; | ||
|
||
let updateProgress = null; | ||
|
||
const updateProgressCallbacks = []; | ||
export const onUpdateProgress = (callback) => { | ||
if (updateProgress) callback(updateProgress); | ||
else updateProgressCallbacks.push(callback); | ||
}; | ||
|
||
export const registerUpdateProgress = (info) => { | ||
updateProgress = info; | ||
updateProgressCallbacks.forEach((cb) => cb(info)); | ||
}; | ||
|
||
export const registerUpdate = (info) => { | ||
updateAvailable = info; | ||
document.body.setAttribute("data-update-available", JSON.stringify(info)); | ||
updateAvailableCallbacks.forEach((cb) => cb(info)); | ||
}; |