Created
September 23, 2011 08:07
-
-
Save amay077/1236944 to your computer and use it in GitHub Desktop.
Reactive4Java のサンプルコード
This file contains 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
Reactive.select( | |
Reactive.where( | |
Reactive.range(1, 10), // <---------------- 元のデータソース {1, 2, 3, 4, 5, 6, 7, 8, 9, 10} | |
new Func1<Integer, Boolean>() { // <----- where:偶数だけにフィルタリング | |
@Override | |
public Boolean invoke(Integer param1) { | |
return param1 % 2 == 0; | |
} | |
}), new Func1<Integer, Integer>() { // <- select:値を10倍に加工 | |
@Override | |
public Integer invoke(Integer param1) { | |
return param1 * 10; | |
} | |
}) | |
.register( | |
Reactive.print() // <------------------- 受信した結果をコンソールに出力 | |
); | |
// Output: | |
// 20, 40, 60, 80, 100 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment