Refactor message handling in TwythonStreamer #225

Merged
extesy merged 2 commits from master into master 2013-06-21 07:37:48 -07:00

2 commits

Author SHA1 Message Date
Oleg Anashkin
50cee5ede8 Combine two ifs into a single line 2013-06-19 17:43:45 -07:00
Oleg Anashkin
009779dda0 Refactor message handling to be more flexible
New parameter `handlers` has a list of message types for which
corresponding handlers should be called. For example, for message types
['delete', 'limit', 'disconnect'] the handlers on_delete, on_limit,
on_disconnect will be invoked if the streamed message has the
corresponding attribute. If the handler returns True then more handlers
might be invoked, otherwise message processing stops. Before all
handlers are called, special on_success handler is invoked with the same
logic: continue message handling if True is returned.

This approach maintains backwards compatibility by not breaking any
existing behaviors.
2013-06-19 13:15:52 -07:00