Added image generation to blog writer
This commit is contained in:
18
frontend/src/utils/imageBus.ts
Normal file
18
frontend/src/utils/imageBus.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
type ImagePayload = { base64: string; provider?: string; model?: string };
|
||||
|
||||
const subscribers = new Set<(p: ImagePayload) => void>();
|
||||
|
||||
export function publishImage(payload: ImagePayload) {
|
||||
subscribers.forEach((cb) => {
|
||||
try { cb(payload); } catch {}
|
||||
});
|
||||
}
|
||||
|
||||
export function subscribeImage(cb: (p: ImagePayload) => void) {
|
||||
subscribers.add(cb);
|
||||
return () => {
|
||||
subscribers.delete(cb);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user