Ok a tad confused here.
My viewModel
has a property searchString
that I verified only gets set once. However this gets fired twice, making two api calls. Never mind that it shouldn't be firing twice, but there's even a distinctUntilChanged
in there that's not preventing it. If I put a breakpoint in the map
, it definitely hits twice with the same value for queryString
.
RACSignal *searchResultsSignal = [[[[[[[[RACObserve(self, searchString)
ignore:nil]
ignore:@""]
distinctUntilChanged]
deliverOn:[RACScheduler scheduler]]
map:^id (NSString *queryString) {
@strongify(self);
TCThirdPartyAPIType type = [TCAPIIndividual thirdPartyAPITypeForAPITypeString:self.activeAPI.APITypeString];
return [TCThirdPartyAPIHelper fetchResultsForAPIType:type withQueryString:queryString latitude:self.latitude longitude:self.longitude];
}]
switchToLatest]
map:^id(TCAPIResponse *response) {
return response.result.array;
}] catch:^RACSignal *(NSError *error) {
return [RACSignal return: @[]];
}];
Forgot to mention that if I subscribe directly to RACObserve(self, searchString)
, and insert a breakpoint, that only catches once.
Shit. Nevermind. Subscribed to twice.
Your comment saved my live :D
I've had this problem before锛宨 use uitextfiled锛學hen I listen for text锛宼he signal firing twice,beause of the uitextfiled isFirstResponder changed,when isFirstResponder is NO fired,is YES fired
Most helpful comment
Your comment saved my live :D