冷信号转换的热信号,如何同步dispose掉源信号

看源码,autoconnect

- (RACSignal *)autoconnect {
    __block volatile int32_t subscriberCount = 0;

    return [[RACSignal
        createSignal:^(id subscriber) {
            OSAtomicIncrement32Barrier(&subscriberCount);

            RACDisposable *subscriptionDisposable = [self.signal subscribe:subscriber];
            RACDisposable *connectionDisposable = [self connect];

            return [RACDisposable disposableWithBlock:^{
                [subscriptionDisposable dispose];

                if (OSAtomicDecrement32Barrier(&subscriberCount) == 0) {
                    [connectionDisposable dispose];
                }
            }];
        }]
        setNameWithFormat:@"[%@] -autoconnect", self.signal.name];
}

在autoconnect里有调用[connectionDisposable dispose];而ReactiveCoca里的replay族方法如replayLazily,用的connect,却对返回的connectionDisposable没有处理,会导致后果 connection.signal结束了而没有dispose掉source signal

你可能感兴趣的:(冷信号转换的热信号,如何同步dispose掉源信号)