pubnub / javascript

PubNub JavaScript SDK docs https://www.pubnub.com/docs/sdks/javascript
Other
552 stars 403 forks source link

Undocumented callback arguments #20

Closed herzi closed 10 years ago

herzi commented 10 years ago

A your API reference at https://www.pubnub.com/docs/javascript/api/reference.html#subscribe does not describe the arguments being passed to the callbacks, I started to add code like this to my callback method:

log('callback called with', arguments.length, 'argument(s)');
for (var i = 0; i < arguments.length; i += 1) {
    log('    ', i + 1, ':', arguments[i]);
}

And thus, I realized that your small examples only care about the first first argument for the callback parameter: message.

The other three arguments are not documented.

Here are my conclusions, please verify and update the API reference:

parasyte commented 10 years ago

These arguments are undocumented because they are for "private" use. Only the JavaScript SDK exposes this data to user code. Other SDKs like Python do not, so documenting it would not be helpful in the "grand scheme".

What you are calling bucket is the full subscription envelope received from the server (before it is parsed by the client SDK). And the someNumber is a calculation of network jitter; effectively the latency between when a message was published, and when you received it.

stephenlb commented 10 years ago

:+1: @parasyte

herzi commented 10 years ago

Would it make sense to remove the other three arguments soon? (Before someone starts relying on those.)

stephenlb commented 10 years ago

These arguments will always be supported for the version of that SDK. New arguments are on the way with our Subscribe V2 coming out. Everything will always be backwards compatible.