Identifying Disconnected Hooks on hook::disconnected

35 views
Skip to first unread message

Jeremy Martin

unread,
May 2, 2012, 3:35:39 PM5/2/12
to hoo...@googlegroups.com
For some of the stuff I'm working on (and it would seem in general), it would be handy to be able to identify which hook disconnected when reacting to a hook::disconnected event.

Currently the data associated with this event contains the name of the server hook, as well as the proposedRank.  If this idea seems sane, I would suggest that simply using the name of the disconnected hook instead of the server hook might make sense, but I'm not sure if and how the current value is used internally.  If that doesn't work, details about the disconnected hook could simply be stored in another property.

Thoughts?

Marak Squires

unread,
May 2, 2012, 3:43:27 PM5/2/12
to hoo...@googlegroups.com
Seems you've got two different problems going on here. 

If you want to add more metadata to the disconnect event, try adding it here: https://github.com/hookio/hook.io/blob/master/lib/hookio/hook.js#L688

As for event names, there are many open discussions on this. 
--
-- 
Marak Squires
Co-founder and Chief Evangelist
Nodejitsu, Inc.

Jeremy Martin

unread,
May 2, 2012, 3:56:27 PM5/2/12
to hoo...@googlegroups.com
Thanks. I'll submit a patch that adds a new property with details on the disconnected hook. I'm not sure what a good name for that is, so I'll just go with `disconnected` if that sounds ok.  Example usage would be:

someHook.on('*::hook::disconnected', function(data) {
    console.log(data.disconnected.name + ' is no longer connected');
});

Jeremy Martin

unread,
May 2, 2012, 4:57:59 PM5/2/12
to hoo...@googlegroups.com
Submitted the pull request: https://github.com/hookio/hook.io/pull/193

Jeremy Martin

unread,
May 3, 2012, 11:12:17 AM5/3/12
to hoo...@googlegroups.com
Thanks for the merge! Any chance of a version bump/npm publish in the near future?
Reply all
Reply to author
Forward
0 new messages