Skip to content
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

Implement per-subscription lifecycle #61

Merged
merged 1 commit into from Oct 21, 2015

Conversation

@kpdecker
Copy link
Contributor

kpdecker commented Oct 19, 2015

Allows setup and teardown logic for a given subscription endpoint.

Fixes #57

@@ -222,7 +224,7 @@ internals.Listener.subscription = function (path, options) {
};

var config = {
subscribers: new internals.Subscribers(),
subscribers: new internals.Subscribers(settings.onSubscribe, settings.onUnsubscribe),

This comment has been minimized.

Copy link
@hueniverse

hueniverse Oct 19, 2015

Member

Pass settings. Call it options on the constructor side.

API.md Outdated
`function(socket, path)`
- `socket` - the [`Socket`](#socket) object of the incoming connection.
- `path` - the path the client subscribed to
- `onUnsubscribe` - Callback called when a client unsubscribes to this subscription endpoint.

This comment has been minimized.

Copy link
@hueniverse

hueniverse Oct 19, 2015

Member

unsubscribe from

}

delete this._items[socket.id];

This comment has been minimized.

Copy link
@hueniverse

hueniverse Oct 19, 2015

Member

Drop this empty line.

@@ -432,10 +445,13 @@ internals.Subscribers.prototype.remove = function (socket, path) {

if (item.paths.length === 1) {
delete this._items[socket.id];
return;
} else {

This comment has been minimized.

Copy link
@hueniverse

hueniverse Oct 19, 2015

Member

else on new line.

if (!item) {
if (!path) {
if (this._onUnsubscribe) {
this._onUnsubscribe(socket);

This comment has been minimized.

Copy link
@hueniverse

hueniverse Oct 19, 2015

Member

I don't like this inconsistent behavior. We should be able to find the paths and provide them, maybe as an array or multiple calls?

@hueniverse hueniverse added the feature label Oct 19, 2015
@hueniverse hueniverse self-assigned this Oct 19, 2015
Allows setup and teardown logic for a given subscription endpoint.

Fixes #57
@kpdecker kpdecker force-pushed the subscription-lifecycle branch from 4900d52 to a98c80d Oct 19, 2015
@kpdecker

This comment has been minimized.

Copy link
Contributor Author

kpdecker commented Oct 19, 2015

Addressed the items above and rebased.

@hueniverse hueniverse added this to the 1.1.0 milestone Oct 21, 2015
hueniverse added a commit that referenced this pull request Oct 21, 2015
Implement per-subscription lifecycle
@hueniverse hueniverse merged commit ec2b58b into master Oct 21, 2015
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
@hueniverse hueniverse deleted the subscription-lifecycle branch Oct 21, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.