Connect
将冷信号包装成热信号,初始化冷信号,调用publish
方法会自动生成一个RACMulticastConnection
,该对象持有了原始信号和一个热信号。
- (RACMulticastConnection *)publish {
RACSubject *subject = [[RACSubject subject] setNameWithFormat:@"[%@] -publish", self.name];
RACMulticastConnection *connection = [self multicast:subject];
return connection;
}
- (RACMulticastConnection *)multicast:(RACSubject *)subject {
[subject setNameWithFormat:@"[%@] -multicast: %@", self.name, subject.name];
RACMulticastConnection *connection = [[RACMulticastConnection alloc] initWithSourceSignal:self subject:subject];
return connection;
}
调用connect
方法来触发订阅,注意调用一次触发一次。