-
Notifications
You must be signed in to change notification settings - Fork 266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Delete observer associated with a topic when cleanup function is called #60
Delete observer associated with a topic when cleanup function is called #60
Conversation
Multiple topics can be associated with a client. This happens when multiple subscriptions are live on a single API. In that case, clientTopics holds client => [topics]. When the cleanup function is called, we should look for a topic within an existing list of topics associated with the client to identify it. Doing this allows us to find the correct <topic, client> pair which allows us to unsubsribe the client from the topic and remove the observer tied to the topic. Leaving a "completed" observer in `topicObserver` will lead to it being reused if we cancel a subscription and then switch back to it. However since the observer has been "completed", its `next` function would never be called. In `unsubscribeFromTopic` function, we should not delete a `client` key if the list of subscribed topics is empty: the client has not been disconnected yet. The client will be disconnected when `disconnectAll` is called the next time `request` is invoked (next subscription setup).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to double check this tomorrow
} else { | ||
this.clientTopics.delete(client); | ||
} | ||
this.clientTopics.set(client, topics); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pending: review what happen if client expires
} else { | ||
this.clientTopics.delete(client); | ||
} | ||
this.clientTopics.set(client, topics); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pending: review what happen if client expires
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Reviewed this morning
thanks guys, this is huge! Will this be deployed to npm soon? Thanks. |
Hi @menkveldj This is in npm now :) |
You rock! I've got a 0.1 release tomorrow. This is just in time to test and
release with real offline first! Thanks.
Sent from my cell: XXX.XXX.XXXX
* All contents contained within this email and subsequent emails are
confidential unless otherwise stated.
…On Feb 28, 2018 7:45 PM, "Manuel Iglesias" ***@***.***> wrote:
Hi @menkveldj <https://github.com/menkveldj>
This is in npm now :)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#60 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AVTPmTDNY86snrKIlTgZ4jOQyrxy9B_3ks5tZ0SNgaJpZM4SUerU>
.
|
Multiple topics can be associated with a client. This happens when
multiple subscriptions are live on a single API. In that case,
clientTopics holds client => [topics]. When the cleanup function is
called, we should look for a topic within an existing list of topics
associated with the client to identify it. Doing this allows us to find
the correct <topic, client> pair which allows us to unsubsribe the
client from the topic and remove the observer tied to the topic. Leaving
a "completed" observer in
topicObserver
will lead to it being reusedif we cancel a subscription and then switch back to it. However since
the observer has been "completed", its
next
function would never becalled.
In
unsubscribeFromTopic
function, we should not delete aclient
key if thelist of subscribed topics is empty: the client has not been disconnected
yet. The client will be disconnected when
disconnectAll
is called thenext time
request
is invoked (next subscription setup).