racsignal

Splitting an RACSignal to eliminate state

我只是一个虾纸丫 提交于 2019-12-20 08:06:30
问题 I'm using ReactiveCocoa to update a UILabel whilst a UIProgressView counts down: NSInteger percentRemaining = ...; self.progressView.progress = percentRemaining / 100.0; __block NSInteger count = [self.count]; [[[RACSignal interval:0.05 onScheduler:[RACScheduler mainThreadScheduler]] take: percentRemaining] subscribeNext:^(id x) { count++; self.countLabel.text = [NSString stringWithFormat:@"%d", count]; self.progressView.progress = self.progressView.progress - 0.01; } completed:^{ // Move

Return RACSignal method in Swift

眉间皱痕 提交于 2019-12-13 00:12:45
问题 I have the following method in Obj-C: - (RACSignal *)fetchCurrentConditionsForLocation:(CLLocationCoordinate2D)coordinate { NSString *urlString = [NSString stringWithFormat:@"http://api.openweathermap.org/data/2.5/weather?lat=%f&lon=%f&units=metric", coordinate.latitude, coordinate.longitude]; NSURL *url = [NSURL URLWithString:urlString]; return [[self fetchJSONFromURL:url] map:^(NSDictionary *json) { return [MTLJSONAdapter modelOfClass:[WXCondition class] fromJSONDictionary:json error:nil];

Migrate from RACSignal to ReactiveSwift or RAC5

白昼怎懂夜的黑 提交于 2019-12-10 21:05:20
问题 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

Reactive Cocoa 5 and ReactiveSwift network requests handling

为君一笑 提交于 2019-12-10 14:54:25
问题 I'm trying to figure out if network requests handling can be implemented suitable to my needs using ReactiveSwift and RAC5. Under topic Migrate from RACSignal to ReactiveSwift or RAC5 I was told it can be done with SignalProducer, but digging deeper into it didn't give me expected results So, I would want to have: 1. Each time text changes in textField send request (search by keyword). 2. Once user closes current ViewController, the current request should be cancelled automatically 3. Have an

Splitting an RACSignal to eliminate state

纵饮孤独 提交于 2019-12-02 14:15:37
I'm using ReactiveCocoa to update a UILabel whilst a UIProgressView counts down: NSInteger percentRemaining = ...; self.progressView.progress = percentRemaining / 100.0; __block NSInteger count = [self.count]; [[[RACSignal interval:0.05 onScheduler:[RACScheduler mainThreadScheduler]] take: percentRemaining] subscribeNext:^(id x) { count++; self.countLabel.text = [NSString stringWithFormat:@"%d", count]; self.progressView.progress = self.progressView.progress - 0.01; } completed:^{ // Move along... }]; This works well enough but, I'm not particularly happy with either the count variable or with