From 814f46c119792aaa240d0fcdb318dccdd1cc0e87 Mon Sep 17 00:00:00 2001 From: Denis Badurina Date: Fri, 28 Aug 2020 13:07:14 +0200 Subject: [PATCH] fix: add the sink to the subscribed map AFTER emitting a subscribe message --- src/client.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/client.ts b/src/client.ts index ab055e0f..0fae9c88 100644 --- a/src/client.ts +++ b/src/client.ts @@ -252,7 +252,6 @@ export function createClient(options: ClientOptions): Client { return; } - subscribedSinks[uuid] = sink; messageListener = socky.registerMessageListener(({ data }) => { const message = parseMessage(data); switch (message.type) { @@ -285,6 +284,9 @@ export function createClient(options: ClientOptions): Client { payload, }), ); + + // the sink is now subscribed + subscribedSinks[uuid] = sink; }) .catch(sink.error);