So, in order to do this, to do what we need,
first we're going to define a new class, okay?
Our own homemade class that extends TwythonStreamer.
So what we mean by extend is that it's a subclass of TwythonStreamer.
So that means, whatever data and
whatever methods TwythonStreamer has, our new class will have those methods.
It'll inherit those, okay.
So we define that, so we'll make a class, call it MyStreamer for
the lack of a better name.
And in parenthesis you put TwythonStreamer to say, look we want to inherit,
we want to extend TwythonStreamer.
So MyStreamer now has all the same stuff that TwythonStreamer had.
And you might ask, well why would I make a new class if it's just going to inherit
everything that TwythonStreamer had?
Well the reason why is because you want to be able to redefine some of the methods of
TwythonStreamer.
So TwythonStreamer has a set of methods, and with certain names, and
we want to redefine some of those.
Okay, to do something different.
So by making this new class, MyStreamer and extending it from TwythonStreamer,
we get all the original methods and data, but we could change them if we want to.
So that's exactly what we're going to do, one in particular, actually.
So now, you're going to define a method, or really redefine a method,
called on_success() inside your new class.
So TwythonStreamer has this on_success().
But you are going to redefine that to our own thing.
Now, note that this on_success() is called a callback, okay?
Now callback, we've actually talked about this a little bit before with GUIs.
A callback is basically a function that's not called by your code directly,
it's called as a result of something else outside of your code occurring.
So when you're talking with graphic user interfaces, a callback is usually used,
like say you click on a button, then you want something to happen, right?
So that something that's going to happen, you write a function for that.
And that function is called whenever a human clicks on a button, okay?
So it is outside of the program's direct control, right?
You don't know when a human's going to click on the button.
But when they do, the callback is invoked.
The function that is a callback,
associated with that button click that is invoked, okay?
So that's the general idea of a callback.
There is some event outside of your code.
And you don't know when it's going to occur.
When it occurs, then the callback fuction associated is called.
So on_success() is a callback, on_success() is called
when a tweet is found that matches the criteria you're looking for.
So remember we talked about this filter function, right?
And we'll show this again.
But we talked about this statuses.filter method, right?
When this method detects that a string is found in a tweet, in the stream that it's
examining, then when it detects that, it calls on_success().
So this on_success() method, or function of method that you're going to define,
you want this on_success() method to be, to
describe whatever you want to do when you find a tweak that matches your criteria.
So if you're looking for a tweak that says Harris in it, right?
What are you going to do once you find it?
You find it, what do you do?
Maybe you print the tweet.
Maybe you say, I found it.
Maybe you do some processing on it.
Who knows, right?
So on_success() is describing whatever you want to have
happen once the criteria are mashed by a filter operation.
So you're going to have to redefine on_success() to do whatever you want.