This repository has been archived on 2026-11-17. You can view files and clone it, but cannot push or open issues or pull requests.
caelum0x 50d986473e feat: round-6 external harvest (19 more features, all products green)
- gitgram-web (4): per-image alt-text accessibility, "New posts" load-latest pill
- gitgram-backend (1): per-user muted words/tags moderation (MutedWord model + matcher)
- gitgram-mobile (4): swipe-to-action list rows, soft-reset event bus (tap tab scroll-top)
- aitm-api (7): gitnexus api_impact blast-radius/risk endpoints (reuse vendored gitnexus)
- aitm-mcp (3): MCP handshake instructions, context-efficient beads output projections

Note: gitgram-backend adds MutedWord Prisma model — run prisma migrate at deploy.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-28 19:04:16 +03:00

42 lines
1.1 KiB
TypeScript

/**
* Lightweight app-wide event bus.
*
* A "soft reset" is the gesture of re-pressing the already-active bottom tab:
* the active feed scrolls back to the top and reloads the latest content.
* Screens subscribe with `listenSoftReset` and the tab bar fires `emitSoftReset`.
*
* Ported from Bluesky's `src/state/events.ts`, but reimplemented as a tiny
* dependency-free emitter so we do not pull `eventemitter3` into the product.
*/
type EventName = 'soft-reset';
type Listener = () => void;
type UnlistenFn = () => void;
const listeners: Record<EventName, Set<Listener>> = {
'soft-reset': new Set(),
};
function emit(event: EventName): void {
// Copy before iterating so a listener that unsubscribes itself during
// dispatch cannot mutate the set we are walking.
for (const listener of [...listeners[event]]) {
listener();
}
}
function listen(event: EventName, fn: Listener): UnlistenFn {
listeners[event].add(fn);
return () => {
listeners[event].delete(fn);
};
}
export function emitSoftReset(): void {
emit('soft-reset');
}
export function listenSoftReset(fn: Listener): UnlistenFn {
return listen('soft-reset', fn);
}