Questions tagged [reactive-cocoa]

ReactiveCocoa (RAC) is a Swift framework inspired by Functional Reactive Programming. It provides APIs for composing and transforming streams of values.

ReactiveCocoa (RAC) is a Swift framework inspired by Functional Reactive Programming. It provides APIs for composing and transforming streams of values.

860 questions
32
votes
1 answer

Chaining dependent signals in ReactiveCocoa

In ReactiveCocoa, if we chaining several dependent signals, we must use subscribeNext: for the next signal in the chain to receive the value previous signal produced (for example, a result of an asynchronous operation). So after a while, the code…
Sergey Mikhanov
  • 8,880
  • 9
  • 44
  • 54
28
votes
2 answers

A ViewModel pattern for iOS apps with ReactiveCocoa

I'm working on integrating RAC into my project with the goal of creating a ViewModel layer that will allow easy caching/prefetching from the network (plus all of the other benefits of MVVM). I'm not especially familiar with MVVM or FRP yet, and I'm…
Evan Cordell
  • 4,108
  • 2
  • 31
  • 47
28
votes
2 answers

What are the reference ownership semantics of ReactiveCocoa?

When I create a signal and bring it into the scope of a function, its effective retain count is 0 per Cocoa conventions: RACSignal *signal = [self createSignal]; When I subscribe to the signal, it retains the subscriber and returns a disposable…
bvanderveen
  • 763
  • 11
  • 17
26
votes
4 answers

Why Does RACCommand's block return a signal?

I've been learning a lot about ReactiveCocoa but one thing still puzzles me: why does the signal block on RACCommand return a signal itself? I understand the use cases of RACCommand, its canExecute signal and signal block, and how it can be hooked…
Ash Furrow
  • 12,391
  • 3
  • 57
  • 92
25
votes
3 answers

How to using ReactiveCocoa to transparently authenticate before making API calls?

I am using ReactiveCocoa in an app which makes calls to remote web APIs. But before any thing can be retrieved from a given API host, the app must provide the user's credentials and retrieve an API token, which is then used to sign subsequent…
bvanderveen
  • 763
  • 11
  • 17
23
votes
1 answer

Difference between RACAble(), RACObserve() and RACBind() in Reactive Cocoa

I'm new to Reactive Programming. I have gone through the documentation of Reactive Cocoa but couldn't realize the differences between RACAble(), RACObserve() and RACBind(). Please, help ,me in understanding the aspects by some example code…
TryinHard
  • 4,078
  • 3
  • 28
  • 54
23
votes
1 answer

Objective-C self->_ivar access with explicit vs implicit self->

General Problem Until now, I always thought self->_ivar is equivalent to _ivar. Today I found out that this is not entirely true. See, for example the following code snippet: @interface TestClass : NSObject { NSString…
Johannes Weiss
  • 52,533
  • 16
  • 102
  • 136
23
votes
2 answers

Has anybody made self updating mutable table view based on a RACSignal?

Now that there's a full support for KVO, has anybody made a mutable table view that takes a RACSignal as its dataSource? Ideally something that doesn't require any configuration. RACSignal *commentsSignal; UITableView *table = [UITableView…
Michael
  • 1,212
  • 1
  • 14
  • 17
22
votes
3 answers

Explanation of how weakify and strongify work in ReactiveCocoa / libextobjc

I understand that you should use @weakify @strongify to avoid retain cycles but I don't completely understand how they actually achieve this?
nacross
  • 2,013
  • 2
  • 25
  • 37
22
votes
1 answer

Difference between catch: and subscribeError:

In ReactiveCocoa, what's the difference between the subscribeError: method vs. catch:? Why would you want to return a signal in catch:?
Ash Furrow
  • 12,391
  • 3
  • 57
  • 92
20
votes
5 answers

Confusion about flatMapLatest in RxSwift

I learn the sample code in RxSwift. In the file GithubSignupViewModel1.swift, the definition of validatedUsername is: validatedUsername = input.username //the username is a textfiled.rx_text .flatMapLatest { username ->…
leizh00701
  • 1,893
  • 5
  • 21
  • 32
19
votes
3 answers

How to use Reactive Cocoa with notifications

How can I create a signal out of a notification name? For example, I want to go from: [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(userDidChange:) …
meisel
  • 2,151
  • 2
  • 21
  • 38
18
votes
6 answers

Two way binding in RxSwift

I read the two way binding operator in sample code of RxSwift. func <-> (property: ControlProperty, variable: Variable) -> Disposable { let bindToUIDisposable = variable.asObservable() .bindTo(property) let bindToVariable =…
leizh00701
  • 1,893
  • 5
  • 21
  • 32
18
votes
2 answers

ReactiveCocoa example with NSMutableArray push/pop?

Could someone provide a one-line example of using ReactiveCocoa abstractions to achieve something like this: // pseudo-code NSMutableArray *array = @[[] mutableCopy]; RACSignal *newValue = RACAbleWithStart(array); // get whole array or maybe just…
Nik
  • 9,063
  • 7
  • 66
  • 81
17
votes
2 answers

Emit an event manually in RxSwift

I'm a newbie in RxSwift and need a very basic help. Assump that I have an Observable and subscribe it like this. let source: Observable = Observable.create { [weak self] observer in guard let _ = self else { …
dummy307
  • 193
  • 1
  • 2
  • 6
1
2 3
57 58