fix: controller is already closed trpc subscription observable error (#743)

This commit is contained in:
Meier Lukas
2024-07-03 20:31:06 +02:00
committed by GitHub
parent f557fbbae1
commit 41dba7b516
6 changed files with 33 additions and 12 deletions

View File

@@ -13,12 +13,19 @@ export const smartHomeRouter = createTRPCRouter({
entityId: string;
state: string;
}>((emit) => {
let isConnectionClosed = false;
homeAssistantEntityState.subscribe((message) => {
if (isConnectionClosed) return;
if (message.entityId !== input.entityId) {
return;
}
emit.next(message);
});
return () => {
isConnectionClosed = true;
};
});
}),
switchEntity: publicProcedure