RACSignal interval does not work right away

I am trying to use the interval method of the RACSignal class for ReactiveCocoa. The following code works every second after 1 second. But I want it to work immediately and every second. What is the best way?

@weakify(self); [[[RACSignal interval:1.0] takeUntilBlock:^BOOL(id x) { return [AClass count] == 0; }] subscribeNext:^(id x) { dispatch_async(dispatch_get_main_queue(), ^{ @strongify(self); NSUInteger count = [AClass count]; self.title = [NSString stringWithFormat:@"%u", count]; }); } completed:^{ dispatch_async(dispatch_get_main_queue(), ^{ @strongify(self); self.title = @""; }); }]; 
+4
source share
1 answer

I believe you are looking for -startWith:

 [[[RACSignal interval:1] startWith:NSDate.date] takeUntilBlock:^(id _) { // ... 
+6
source

All Articles