cstephen / hashtag-count

Count hashtag occurrences over time using Twitter's Streaming API.
MIT License
7 stars 4 forks source link

Allow optional settings to be set individually, not just all at once #4

Closed cstephen closed 7 years ago

cstephen commented 7 years ago

With the addition of three more possible callbacks, passing all optional settings into the start() method all at once is starting to become unruly:

hc.start({
  hashtags: hashtags,               // required
  interval: interval,               // required
  history: history,                 // optional
  intervalCb: intervalCb,           // optional
  connectingCb: connectingCb,       // optional
  reconnectingCb: reconnectingCb,   // optional
  connectedCb: connectedCb,         // optional
});

It should remain possible to set them this way, but it would be even better to support setting them more directly and individually like this:

hc.intervalCb = function () {
  // Some code.
};

This also eliminates the need for identically/awkwardly named intermediate variables to store the callbacks.

cstephen commented 7 years ago

I've decided this change would do more harm than good because it would give the impression that certain settings can be changed at any time, even after a process has already started.

For example, a change to hashtags cannot take effect until the Twitter Streaming API connection is restarted (which should be done infrequently to avoid rate limiting). Also, it's hard to think of a use case where somebody would want to change the limit or interval settings in the middle of the process.

The various callbacks could technically be changed on the fly, but again, it's hard to imagine a use case for this. It wouldn't warrant the additional confusion, in my opinion.