title: ReactiveCocoa: flattenMap or map
body: <p>I'm using ReactiveCocoa to develop a little app to do some local search. It looks like this:</p>
  
  <pre><code>    - (void)awakeFromNib {
      ...
      [[[[RACObserve(self, currentLocation) ignore:nil]
         flattenMap:^(CLLocation *newLocation) {
             return [self updateRestroomArray];
         }] deliverOn:RACScheduler.mainThreadScheduler]
       subscribeError:^(NSError *error) {
           NSLog(@"ERROR : %@", error);
       }];
       ...
  }
  
  // Store result
  - (RACSignal *)updateRestroomArray
  {
      return [[self searchRestroomForCoordinate:self.currentLocation.coordinate]
              doNext:^(NSArray *mapItems) {
                  self.restroomArray = mapItems;
              }];
  }
  
  // local search
  - (RACSignal *)searchRestroomForCoordinate:(CLLocationCoordinate2D)coordinate
  {
      return [RACSignal createSignal:^RACDisposable *(id&lt;RACSubscriber&gt; subscriber) { 
          MKCoordinateRegion searchRegion = MKCoordinateRegionMakeWithDistance(coordinate, 300, 300);
          self.restroomSearchRequest.region = searchRegion;
          MKLocalSearch *localSearch = [[MKLocalSearch alloc] initWithRequest:self.restroomSearchRequest];
          [localSearch startWithCompletionHandler:^(MKLocalSearchResponse *response, NSError *error) {
              if (error) {
                  [subscriber sendError:error];
              } else if (0 == response.mapItems.count) {
                  NSError *noResultError = [[NSError alloc] initWithDomain:@"com.gnou.emergency.search" code:100 userInfo:@{@"testKey":@"testValue"}];
                  [subscriber sendError:noResultError];
              } else {
                  [subscriber sendNext:response.mapItems];
              }
              [subscriber sendCompleted];
          }];       
          return [RACDisposable disposableWithBlock:^{
              [localSearch cancel];
          }];
      }];
  }
  </code></pre>
  
  <p>When I use <strong>flattenMap</strong> in <em>awakeFromNib</em>, it works fine, I'll get the result, but when I use '<strong>map</strong>', <em>localSearch</em> just doesn't do the search job, why? I can't see anything need to be 'flattened'.</p>