You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
549 B
29 lines
549 B
6 years ago
|
let currentPopulator = null;
|
||
|
let currentReasons = [];
|
||
|
|
||
|
export function registerPagePopulator(populator, reasons = []) {
|
||
|
currentPopulator = populator;
|
||
|
currentReasons = reasons;
|
||
|
}
|
||
|
|
||
|
export function unregisterPagePopulator(populator) {
|
||
|
if (currentPopulator === populator) {
|
||
|
currentPopulator = null;
|
||
|
currentReasons = [];
|
||
|
}
|
||
|
}
|
||
|
|
||
|
export function repopulatePage(reason) {
|
||
|
if (!currentPopulator) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (!reason) {
|
||
|
currentPopulator();
|
||
|
}
|
||
|
|
||
|
if (reason && currentReasons.includes(reason)) {
|
||
|
currentPopulator();
|
||
|
}
|
||
|
}
|