Initial commit: MVP+ wish board with FastAPI + Tailwind

This commit is contained in:
Nikita committed 2026-08-05 17:06:36 +05:00
commit cd945a6128
2277 files changed
+843095

No files matched your search

@@ -0,0 +1,43 @@
import type { Announce } from '../../../types';
import { warning } from '../../../dev-warning';
export type ExpiringAnnounce = Announce & {
wasCalled: () => boolean;
};
export default (announce: Announce): ExpiringAnnounce => {
let wasCalled = false;
let isExpired = false;
// not allowing async announcements
const timeoutId: TimeoutID = setTimeout(() => {
isExpired = true;
});
const result = (message: string): void => {
if (wasCalled) {
warning('Announcement already made. Not making a second announcement');
return;
}
if (isExpired) {
warning(`
Announcements cannot be made asynchronously.
Default message has already been announced.
`);
return;
}
wasCalled = true;
announce(message);
clearTimeout(timeoutId);
};
// getter for isExpired
// using this technique so that a consumer cannot
// set the isExpired or wasCalled flags
result.wasCalled = (): boolean => wasCalled;
return result;
};