Files
t3code/apps/mobile/src/state/thread-outbox.ts
T

30 lines
1008 B
TypeScript

import type { EnvironmentId } from "@t3tools/contracts";
import { appAtomRegistry } from "./atom-registry";
import { createThreadOutboxManager } from "./thread-outbox-manager";
import type { QueuedThreadMessage } from "./thread-outbox-model";
import { expoThreadOutboxStorage } from "./thread-outbox-storage";
export * from "./thread-outbox-model";
export const threadOutboxManager = createThreadOutboxManager({
registry: appAtomRegistry,
storage: expoThreadOutboxStorage,
});
export function ensureThreadOutboxLoaded(): void {
void threadOutboxManager.load();
}
export function enqueueThreadOutboxMessage(message: QueuedThreadMessage): Promise<void> {
return threadOutboxManager.enqueue(message);
}
export function removeThreadOutboxMessage(message: QueuedThreadMessage): Promise<void> {
return threadOutboxManager.remove(message);
}
export function clearThreadOutboxEnvironment(environmentId: EnvironmentId): Promise<void> {
return threadOutboxManager.clearEnvironment(environmentId);
}