Skip to content

Instantly share code, notes, and snippets.

@amay077
Created September 23, 2011 08:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amay077/1236944 to your computer and use it in GitHub Desktop.
Save amay077/1236944 to your computer and use it in GitHub Desktop.
Reactive4Java のサンプルコード
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