groupBy() 공개 메소드

Groups the elements of an observable sequence according to a specified key selector function and comparer and selects the resulting elements by using a specified function.
public groupBy ( callable $keySelector, callable $elementSelector = null, callable $keySerializer = null ) : Rx\Observable\AnonymousObservable
$keySelector callable
$elementSelector callable
$keySerializer callable
리턴 Rx\Observable\AnonymousObservable
예제 #1
0
 /**
  * @param Observable $observable
  * @return Observable\AnonymousObservable
  */
 public function summarize(Observable $observable)
 {
     return $observable->groupBy(function (FileWithDate $file) {
         return $file->getDatePath();
     }, function (FileWithDate $file) {
         return $file->getDatePath();
     }, function ($key) {
         return $key;
     })->flatMap(function (GroupedObservable $g) {
         return $g->zip([$g->distinct(), $g->count()], function ($_, $b, $c) {
             return "Created {$b} with {$c} files";
         });
     });
 }