天道酬勤,学无止境

reactive-cocoa

Reactive Cocoa limit a signal to only one subscriber at once

问题 我需要在 RAC 中建模。 我有一个 tabBarController 将订阅通知信号。 说推送通知。 还说当前活动的视图控制器也可能想要订阅相同的信号。 但是,如果任何订阅它的视图控制器 tabBarController 不想处理它。 否则它将处理它。 此外,当当前可见视图控制器发生变化时。 它需要将责任委托给 tabController。 目前没有 RAC,我在 tabController 维护了一系列观察者。 如果有任何观察员出席特定类型的通知。 它将委托给 viewController 否则 tabController 将处理它。 使用 RAC 进行建模的更好方法是什么?

2022-05-13 07:49:17    分类:技术分享    ios   swift   reactive-cocoa   frp

Why the signal is called twice in ReactiveCocoa?

问题 我正在使用 https://github.com/ReactiveCocoa/ReactiveCocoa 实现我的第一个代码。 用于登录用户。 行[subscriber sendNext:user]; 被调用了两次,但我希望只有一次。 并且地图根本没有被调用(所以自动登录永远不会被调用) 这是我的实现: -(RACSignal *) login:(NSString *)email pwd:(NSString *)pwd { DDLogInfo(@"Login user %@", email); RACSignal *login = [RACSignal createSignal:^ RACDisposable *(id<RACSubscriber> subscriber) { [PFUser logInWithUsernameInBackground:email password:pwd block:^(PFUser *user, NSError *error) { if (error) { [subscriber sendError:error]; } else { [subscriber sendNext:user]; [subscriber sendCompleted]; } }]; return nil; }]; [login map:^(PFUser *user)

2022-05-06 19:39:12    分类:技术分享    ios   objective-c   reactive-programming   reactive-cocoa

Migrate from RACSignal to ReactiveSwift or RAC5

问题 我是 Swift 的新手,这就是为什么我是 Reactive Cocoa v5 或 Reactive Swift 的新手。 以前我将 RACSignal 与 RAC 2.x 一起使用,我喜欢做这样的事情: - (RACSignal *)signalForGET:(NSString *)URLString parameters:(NSDictionary *)parameters { return [RACSignal createSignal:^RACDisposable *(id <RACSubscriber> subscriber) { AFHTTPRequestOperation *op = [self GET:URLString parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) { [subscriber sendNext:responseObject]; [subscriber sendCompleted]; } failure:^(AFHTTPRequestOperation *operation, NSError *error) { [subscriber sendError:error]; }]; return [RACDisposable

2022-05-01 15:13:24    分类:技术分享    swift   reactive-cocoa   reactive   racsignal   reactive-swift

Reactive Cocoa limit a signal to only one subscriber at once

I need to model following in RAC. I have a tabBarController which will subscribe to a notification signal. Say push notification. Also say currently active view controller may also be want to subscribe to the same signal. But if any view controller subscribed to it tabBarController doesn't want to handle it. Otherwise it will handle it. Also when current visible view controller changes. It needs to delegate back the responsibility to tabController. Currently without RAC I maintain array of observers at tabController. If any observer present for particular kind of notification. It will delegate

2022-04-30 07:58:09    分类:问答    ios   swift   reactive-cocoa   frp

Why the signal is called twice in ReactiveCocoa?

I'm implementing my first code with https://github.com/ReactiveCocoa/ReactiveCocoa. Is for login a user. The line [subscriber sendNext:user]; is called twice, but I expect to be only one. And the map is not called at all (so autologin is never called) This is my implementation: -(RACSignal *) login:(NSString *)email pwd:(NSString *)pwd { DDLogInfo(@"Login user %@", email); RACSignal *login = [RACSignal createSignal:^ RACDisposable *(id<RACSubscriber> subscriber) { [PFUser logInWithUsernameInBackground:email password:pwd block:^(PFUser *user, NSError *error) { if (error) { [subscriber sendError

2022-04-29 04:06:08    分类:问答    ios   objective-c   reactive-programming   reactive-cocoa

ReactiveCocoa takeUntil 2 possible signals?

问题 所以我已经成功地将一个按钮变成了一个可以改变标签的开关。 我还能够让它在发生这种情况时启动定时处理设置,并且它能够关闭定时处理。 无论如何,我需要关闭定时过程,我想知道是否有办法在不使用一次性用品的情况下停止它。 使用第二个 takeUntil 信号。 编辑我认为我试图做的有点误导让我展示我当前的有效解决方案。 -(RACSignal*) startTimer { return [[RACSignal interval:1.0 onScheduler:[RACScheduler mainThreadScheduler]] startWith:[NSDate date]]; } -(void) viewWillAppear:(BOOL)animated {} -(void) viewDidLoad { self.tableView.delegate = self; self.tableView.dataSource = self; RACSignal* pressedStart = [self.start rac_signalForControlEvents:UIControlEventTouchUpInside]; @weakify(self); RACSignal* textChangeSignal = [pressedStart map:^id(id value) {

2022-04-21 08:32:46    分类:技术分享    ios   reactive-cocoa

Migrate from RACSignal to ReactiveSwift or RAC5

I'm new with Swift, and that's why I'm new with Reactive Cocoa v5 or Reactive Swift. Previously I used RACSignal with RAC 2.x and I liked to do something like this: - (RACSignal *)signalForGET:(NSString *)URLString parameters:(NSDictionary *)parameters { return [RACSignal createSignal:^RACDisposable *(id <RACSubscriber> subscriber) { AFHTTPRequestOperation *op = [self GET:URLString parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) { [subscriber sendNext:responseObject]; [subscriber sendCompleted]; } failure:^(AFHTTPRequestOperation *operation, NSError *error

2022-04-06 12:25:49    分类:问答    swift   reactive-cocoa   reactive   racsignal   reactive-swift

How to obtain a UIAlertController observable (ReactiveCocoa or RxSwift)?

I implemented a "reactive" UIAlertController so I can get an Observable<Int> of the button press. (See code below). My question, or questions, are: Is this implementation correct? I don't like storing the observers; I wonder if there's a better solution. Or... is there already an implementation of this in ReactiveCocoa or RxSwift? Here is the implementation. I removed the parts not relevant to te question. class AlertBuilder { typealias AlertAction = (Int) -> () private let alert: UIAlertController /** If observable() is called, we keep here the observers to notify them */ private var

2022-04-04 19:52:54    分类:问答    ios   reactive-cocoa   rx-swift