reactive-cocoaracsignal

If a RACSignal sends next can I wrap it in something which sends completed instead?


A very simple question and I'm overseeing probably a key method in RAC.

Say I've got this simple signal

RACSignal *signal = [[RACSignal return:@"hello"] delay:10]

How can I without changing above code create a new signal which sends completed when any value is passed (in this case @"hello" after 10 seconds)?


Solution

  • Some alternativs

    RACSignal *completeSignal = [[signal take:1] ignoreValues];
    

    RACSignal *completeSignal = [signal flattenMap:^(id value) {
        return [RACSignal empty];
    }];
    

    RACSignal *completeSignal = [signal flattenMap:^(id value) {
        return nil;
    }];