如何根据条件创建Observable

时间:2015-08-05 05:44:54

标签: rx-java

有没有办法根据某些条件创建observable?

例如,如果我有Observable.just(1, 2, 3, ..., n),如果下一个发出的项目是1,那么doSomethingA,如果是5则doSomethignB否则doWithEverythingElse

或者我问得太多了? :)

1 个答案:

答案 0 :(得分:2)

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> <div ng-app="my-app" ng-controller="AppController"> <div ng-class="colorScheme"> <button ng-click="colorScheme = 'red'">ColorScheme Red</button> <button ng-click="colorScheme = 'blue'">ColorScheme Blue</button> <button ng-click="colorScheme = 'green'">ColorScheme Green</button> <p>Awesome content</p> </div> </div>中使用if语句:

doOnNext