Rx-Tweet-Stream

A RxJava Observable wrapper around Twitter Streaming API

License

License

MIT
Categories

Categories

React User Interface Web Frameworks
GroupId

GroupId

com.shekhargulati.reactivex
ArtifactId

ArtifactId

rx-tweet-stream
Last Version

Last Version

0.1.0
Release Date

Release Date

Type

Type

jar
Description

Description

Rx-Tweet-Stream
A RxJava Observable wrapper around Twitter Streaming API
Project URL

Project URL

https://github.com/shekhargulati/rx-tweet-stream
Source Code Management

Source Code Management

https://github.com/shekhargulati/rx-tweet-stream.git

Download rx-tweet-stream

How to add to project

<!-- https://jarcasting.com/artifacts/com.shekhargulati.reactivex/rx-tweet-stream/ -->
<dependency>
    <groupId>com.shekhargulati.reactivex</groupId>
    <artifactId>rx-tweet-stream</artifactId>
    <version>0.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.shekhargulati.reactivex/rx-tweet-stream/
implementation 'com.shekhargulati.reactivex:rx-tweet-stream:0.1.0'
// https://jarcasting.com/artifacts/com.shekhargulati.reactivex/rx-tweet-stream/
implementation ("com.shekhargulati.reactivex:rx-tweet-stream:0.1.0")
'com.shekhargulati.reactivex:rx-tweet-stream:jar:0.1.0'
<dependency org="com.shekhargulati.reactivex" name="rx-tweet-stream" rev="0.1.0">
  <artifact name="rx-tweet-stream" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.shekhargulati.reactivex', module='rx-tweet-stream', version='0.1.0')
)
libraryDependencies += "com.shekhargulati.reactivex" % "rx-tweet-stream" % "0.1.0"
[com.shekhargulati.reactivex/rx-tweet-stream "0.1.0"]

Dependencies

compile (3)

Group / Artifact Type Version
org.twitter4j : twitter4j-stream jar 4.0.4
org.slf4j : slf4j-api jar 1.7.18
io.reactivex : rxjava jar 1.1.1

test (2)

Group / Artifact Type Version
junit : junit jar 4.11
org.slf4j : slf4j-simple jar 1.7.18

Project Modules

There are no modules declared in this project.

rx-twitter-stream Build Status License

RxJava observable for tweet stream. It is a wrapper around Twitter4J Streaming Library. rx-twitter-stream API uses JDK 8.

Getting Started

To use rx-tweet-stream in your application, you have to add rx-tweet-stream in your classpath. rx-tweet-stream is available on Maven Central so you just need to add dependency to your favorite build tool as show below.

For Apache Maven users, please add following to your pom.xml.

<dependencies>
    <dependency>
        <groupId>com.shekhargulati.reactivex</groupId>
        <artifactId>rx-tweet-stream</artifactId>
        <version>0.1.0</version>
        <type>jar</type>
    </dependency>
</dependencies>

Gradle users can add following to their build.gradle file.

compile(group: 'com.shekhargulati.reactivex', name: 'rx-tweet-stream', version: '0.1.0', ext: 'jar')

Usage

The example shown below uses the Twitter4j environment variables

export twitter4j.debug=true
export twitter4j.oauth.consumerKey=*********************
export twitter4j.oauth.consumerSecret=******************************************
export twitter4j.oauth.accessToken=**************************************************
export twitter4j.oauth.accessTokenSecret=******************************************
import com.shekhargulati.reactivex.twitter.TweetStream;

TweetStream.of("java").map(Status::getText).take(10).subscribe(System.out::println);

If you don't want to use environment variables, then you can use the overloaded method that allows you to pass configuration object.

ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setDebugEnabled(true)
        .setOAuthConsumerKey("*********************")
        .setOAuthConsumerSecret("******************************************")
        .setOAuthAccessToken("**************************************************")
        .setOAuthAccessTokenSecret("******************************************");

TweetStream.of(cb.build(), "java").map(Status::getText).take(10).subscribe(System.out::println);

The other of factory methods present in TweetStream are:

Observable<Status> of(final long... usersToFollow)
Observable<Status> of(final String[] languages, final String[] searchTerms)
Observable<Status> of(final Configuration configuration, final String[] languages, final String[] searchTerms)
Observable<Status> of(final Configuration configuration, final String... searchTerms)
Observable<Status> of(final Configuration configuration, final long... usersToFollow)
Observable<Status> of(final Configuration configuration, final String[] languages, final String[] searchTerms, final long[] usersToFollow)

License

rx-tweet-stream is licensed under the MIT License - see the LICENSE file for details.

Credits

TweetSubscriber is inspired by the TwitterObservable of yarn starter.

Versions

Version
0.1.0