This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package java.util; | |
public interface List<E> extends Collection<E> { | |
boolean add(E e); | |
boolean remove(Object o); | |
E get(int index); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
options("/*", | |
(request, response) -> { | |
String accessControlRequestHeaders = request | |
.headers("Access-Control-Request-Headers"); | |
if (accessControlRequestHeaders != null) { | |
response.header("Access-Control-Allow-Headers", | |
accessControlRequestHeaders); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val observable = Observable.just("some event") | |
.map { | |
Thread.sleep(randomInt()) | |
System.currentTimeMillis() | |
} | |
.publish() | |
.autoConnect(2) | |
val sub1 = observable.subscribe({ println("sub1 got : $it") },{}) | |
val sub2 = observable.subscribe({ println("sub2 got : $it") },{}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val observable = Observable.just("some event") | |
.map { | |
Thread.sleep(randomInt()) | |
System.currentTimeMillis() | |
} | |
val sub1 = observable.subscribe({ println("sub1 got : $it") },{}) | |
val sub2 = observable.subscribe({ println("sub2 got : $it") },{}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# .profile | |
export TERM=xterm-256color | |
# .vimrc | |
syntax on | |
set background = dark | |
let g:solarized_termcolors = 256 | |
colorscheme solarized |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Observable<Boolean> emailStream = RxTextView.textChanges(etEmail) | |
.map(new Func1<CharSequence, String>() { | |
@Override | |
public String call(CharSequence charSequence) { | |
return charSequence.toString(); | |
} | |
}) | |
.filter(new Func1<String, Boolean>() { | |
@Override | |
public Boolean call(String input) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.debounce(100,TimeUnit.MILLISECONDS) | |
.map(new Func1<String, Boolean>() { | |
@Override | |
public Boolean call(String s) { | |
// butuh fungsi yang me-return boolean | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Return true jika password yang diketik user < 6 karakter | |
Observable<Boolean> passwordStream = RxTextView.textChanges(etPassword) | |
.map(new Func1<CharSequence, Boolean>() { | |
@Override | |
public Boolean call(CharSequence charSequence) { | |
return !TextUtils.isEmpty(charSequence) | |
&& charSequence.toString().trim().length() < 6; | |
} | |
}); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Ambil daftar email dari APi, kemudian cek apakah email user sudah dipakai | |
public Observable<Boolean> checkIfEmailExistFromAPI(final String input){ | |
return service.getEmails() | |
.flatMap(new Func1<List<String>, Observable<String>>() { // Mengubah stream of List<String> menjadi stream of String | |
@Override | |
public Observable<String> call(List<String> strings) { | |
return Observable.from(strings); | |
} | |
}).contains(input) // Cek apakah email di emit oleh stream sebelumnya | |
.subscribeOn(Schedulers.newThread()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.rohmanhakim.androidreactivedemo; | |
import android.support.v4.view.ViewCompat; | |
import android.support.v7.app.AppCompatActivity; | |
import android.os.Bundle; | |
import android.util.Log; | |
import android.view.View; | |
import android.widget.Button; | |
import android.widget.TextView; |
NewerOlder