Skip to content

Instantly share code, notes, and snippets.

@Hafiz-Waleed-Hussain
Created March 12, 2017 12:09
Show Gist options
  • Save Hafiz-Waleed-Hussain/a3acd794e4942f296531018bdcad2a23 to your computer and use it in GitHub Desktop.
Save Hafiz-Waleed-Hussain/a3acd794e4942f296531018bdcad2a23 to your computer and use it in GitHub Desktop.
ArrayOfInteger using Rx Java 2 Android.
package async.waleed.rx;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import io.reactivex.Observable;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Integer[] data = {1, 2, 3, 4};
Observable.fromArray(data)
.map(value -> value * value)
.map(value -> Integer.toString(value))
.forEach(string -> Log.i("Android", string));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment