Reputation: 904
I have a RACCommand that uses this signal:
- (RACSignal *)getProductsSignal {
return [[RACSignal combineLatest:@[self.currentCategorySignal, self.client.getProducts] reduce:^id(Category *category, NSArray *products) {
return [[products.rac_sequence filter:^BOOL(Product *product) {
return [product belongsToCategory:category];
}] array];
}];
}
The problem im having is that the signal never sends complete, so, the button that is binded with the command will be disabled after the first press forever.
- (RACSignal *)currentCategorySignal {
return RACObserve(self, currentCategory);
}
getProducts looks something like this
- (RACSignal *)getProducts {
NSString *path = @"/products"];
return [[[[self.manager rac_GET:path parameters:nil]
replayLazily]
parseResponseForClass:[TPProduct class]]
transformError];
}
Any suggestion ?
Upvotes: 0
Views: 632
Reputation: 904
The actual problem was with RACObserve. RACObserve only sends complete when the object is deallocated.
Had to change my signals to perform the task I wanted.
Upvotes: 0
Reputation: 7944
I think that take:
signal operator could be used here. It returns a signal which completes as soon as the original signal sends n
next values:
- (RACSignal *)getProductsSignal {
return [[RACSignal combineLatest:@[self.currentCategorySignal, self.client.getProducts] reduce:^id(Category *category, NSArray *products) {
RACSignal *productsSignal = [[products.rac_sequence filter:^BOOL(Product *product) {
return [product belongsToCategory:category];
}] array];
}];
[return productsSignal take:1];
}
Upvotes: 1