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.

857 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,350
  • 9
  • 40
  • 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,068
  • 2
  • 27
  • 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
  • 10
  • 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,341
  • 3
  • 54
  • 91
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
  • 10
  • 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
  • 3,822
  • 3
  • 26
  • 51
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,162
  • 1
  • 13
  • 16
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,053
  • 2
  • 23
  • 34
22
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
  • 47,880
  • 15
  • 95
  • 129
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,341
  • 3
  • 54
  • 91
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
  • 1,783
  • 2
  • 17
  • 30
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
  • 7,782
  • 6
  • 54
  • 79
17
votes
4 answers

How do I create a ReactiveCocoa subscriber that receives a signal only once, then unsubscribes/releases itself?

I'm currently registering a subscriber to a property signal like this: [RACAble(self.test) subscribeNext:^(id x) { NSLog(@"signal fired!"); }]; The default functionality is that it fires every single time self.test is changed, but I just…
zakdances
  • 16,715
  • 30
  • 94
  • 155
16
votes
1 answer

MVVM and pushing a ViewController: where to initialize the next ViewController and ViewModel, and push on the new view?

I'm thinking through the structure of a very simple ViewModel and ViewController for a test application. I have something akin to: FirstViewController.m: - (IBAction)launchButtonSelected:(id)sender { [self.viewModel…
cbowns
  • 5,932
  • 4
  • 41
  • 63
16
votes
2 answers

Meaning of Objective-C macros prefixed with an at (@) symbol

The ReactiveCocoa framework makes use of weakify and strongify macros, both of which are preceded by an '@' symbol. Here's an example (From this file). - (RACSignal *)rac_textSignal { @weakify(self); return [[[[RACSignal …
ColinE
  • 64,631
  • 12
  • 149
  • 215
1
2 3
57 58