A fault tolerant app that listens to filtered tweets via the twitter streaming api and processes them according to a custom lambda function. The lambda function may be synchronous or asynchronous.
npm install twitter-lite npm install twitint
Starting A New Listener
const Client =const Listener =const client_primary =consumer_key: 'consumer_key'consumer_secret: 'consumer_secret'access_token_key: 'access_token_key'access_token_secret: 'access_token_secret'const client_secondary =consumer_key: 'consumer_key'consumer_secret: 'consumer_secret'access_token_key: 'access_token_key'access_token_secret: 'access_token_secret'// instantiate a new Listener using 2 clients with the secondary client acting as a fallbackconst listener = client_primary client_secondary// starting a stream of tweets filtered by tracking termslistener// the app emits a listening event when the active client has started streaminglistener// the app emits an error only when all reconnect attempts have failed, thereby suspending all listenerslistener// the app warns of errors in processing individual tweets and emits a warning whenever the active client connection is interruptedlistener
Updating an Existing Listener
This library allows you to apply updates to the initial listener without severing the connection between your app and twitter. It does this by starting a connection with the updated parameters using the fallback client and only then terminating the primary client. The application shouldn't theoretically lose any data between the switchover since one client remains open while the other is connecting.
// update an existing listenerlistener
// the retrying event is emitted when attempting to reconnectlistener// the updating event is emitted when attempting to update an existing listenerlistener