const unsubscribeRef = yield* Ref.make<(() => void) | undefined>(undefined);
yield* Effect.addFinalizer(() =>
Effect.gen(function* () {
const unsubscribe = yield* Ref.get(unsubscribeRef);
yield* Effect.logInfo("Unsubscribing from loro");
if (unsubscribe) {
unsubscribe();
}
})
);
const changesStream = yield* Stream.asyncEffect<Uint8Array>((emit) =>
Effect.gen(function* () {
yield* Effect.logInfo("Created changes Stream");
const unsubscribe = doc.subscribeLocalUpdates((updates) => {
console.log("Got updates from loro");
emit.single(updates);
});
yield* Ref.set(unsubscribeRef, unsubscribe);
})
).pipe(Stream.share({ capacity: "unbounded" }));
const unsubscribeRef = yield* Ref.make<(() => void) | undefined>(undefined);
yield* Effect.addFinalizer(() =>
Effect.gen(function* () {
const unsubscribe = yield* Ref.get(unsubscribeRef);
yield* Effect.logInfo("Unsubscribing from loro");
if (unsubscribe) {
unsubscribe();
}
})
);
const changesStream = yield* Stream.asyncEffect<Uint8Array>((emit) =>
Effect.gen(function* () {
yield* Effect.logInfo("Created changes Stream");
const unsubscribe = doc.subscribeLocalUpdates((updates) => {
console.log("Got updates from loro");
emit.single(updates);
});
yield* Ref.set(unsubscribeRef, unsubscribe);
})
).pipe(Stream.share({ capacity: "unbounded" }));