I haven't used RCL yet, so let me know if I've used -animateWithDuration:
incorrectly.
First, I've defined a signal that sends @YES
instead of the first status, and @NO
instead of all following statuses. This is done by taking advantage of the -bind:
operator which allows for custom per-subscriber variables via block capture.
RACSignal *isFirstStatus = [statusSignal bind:^{
__block BOOL first = YES;
return ^(id _, BOOL *stop) {
BOOL isFirst = first;
first = NO;
return [RACSignal return:@(isFirst)];
};
}];
Next, put isFirstStatus
together with +if:then:else:
to start with the initial animation signal, and then switch to the permanent animation signal.
RAC(self, statusLabel.alpha) = [[RACSignal
if:isFirstStatus
// Initially, an animation signal to 1.
then:[RACSignal return:@1]
// Subsequently, an animation signal to 0, then, to 1.
else:[[[RACSignal return:@1] delay:animationDuration] startWith:@0]]
animateWithDuration:animationDuration];
I've looked for a way to handle the text property update in-band with the animation via its completion, but didn't find anything I liked. This might be an opportunity to add an operator to RCL for this type of scenario, if there's not already a good way of doing that.