Skip to content

Commit

Permalink
fix: add the sink to the subscribed map AFTER emitting a subscribe me…
Browse files Browse the repository at this point in the history
…ssage
  • Loading branch information
enisdenjo committed Aug 28, 2020
1 parent 62155ba commit 814f46c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/client.ts
Expand Up @@ -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) {
Expand Down Expand Up @@ -285,6 +284,9 @@ export function createClient(options: ClientOptions): Client {
payload,
}),
);

// the sink is now subscribed
subscribedSinks[uuid] = sink;
})
.catch(sink.error);

Expand Down

0 comments on commit 814f46c

Please sign in to comment.