Search code examples
reactive-cocoa

Property vs RACSignal


I just started with ReactiveCocoa (and FRP for that matter) and every time I start refactoring my code to be more RAC-based, I ask myself: when should I create a property or a RACSignal?

For example, if I have a ViewModel that does some checking to see if a button can be enabled or not, should I do this:

dynamic var ready: NSNumber //Bool

Or this:

var ready: RACSignal

Solution

  • If you want to start writing more RAC-based code, then I would highly encourage you to use a RACSignal instead of a value property, for two reasons:

    1. RACSignal use on view models is arguably more idiomatic (i.e.: a more "RAC" way of doing things).
    2. Not having access to the property value at any given time will force you to think in terms of FRP, helping you learn RAC faster.