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.
 
 
 
 
 

23 lines
480 B

export function availableReporter(
positiveMsg: string|null,
negativeMsg: string|null,
positiveAction = console.log,
negativeAction = console.error,
) {
let reported = false;
return available => {
if(available && reported) {
reported = false;
if(positiveMsg) {
positiveAction(positiveMsg);
}
}
if(!available && !reported) {
reported = true;
if(negativeMsg) {
negativeAction(negativeMsg);
}
}
}
};