ReactiveCocoa for CincyCocoaDev Meetup

Preview:

DESCRIPTION

An intro to ReactiveCocoa for iOS

Citation preview

REACTIVECOCOAA Dive into Functional Reactive Programming

SAM CORDER

@samcordersam.corder@pinnsg.com

STATE OF STATE

• KVO

• Callback Blocks

• Delegates

• Target-action mechanisms

• Notifications

CODE

RAC CODE

RAC DEFINED

• RAC Definition

• RAC Birth

• My History

TERMS

• RACStream

• RACSignal

• RACSubscriber

• RACCommand

• RACSequence [Soon to be deprecated]

STREAMS

• Base class for the interesting classes

• Pipes of values retrieved sequentially

• Composed and operated on with operators

SIGNALS• Push driven stream

• Must be subscribed to

• Sends 3 types of events

• Next

• Error

• Complete

TRANSFORMINGOPERATORS

• Mapping - map:

• Filtering - filter:

• Concatenating - concat:

• Flattening - flatten:

• Mapping and Flattening - flattenMap:

COMBINING OPERATORS

• +merge:

• +combineLatest:

• +switchToLatest:

SUBSCRIBER

• subscribeNext:error:completed:

CODE

COMMANDS

• Creates and subscribes to a signal in response to action.

• Can be disabled based on a signal

CODE

MISC GEMS• @weakify/@strongify

• RAC() is a macro that makes the binding look nicer.

• [RACObserve(self, event) subscribeNext:^(Type *vale) {...}];

• [[self rac_signalForSelector:@selector(selector:) fromProtocol:@protocol(SomeDelegate)]

• RACTupleUnpack(Type1 * var1, Type2 * var2…) = args;

MVVMUnder MVVM, the view and view controller become

formally connected; we treat them as one. Views still don’t have references to the model, but neither do controllers. Instead, they reference the view model.

–Lillian Smith

“When you stop learning, stop listening, stop looking and asking questions, always

new questions, then it is time to die.”

RESOURCES• Ray Wenderlich - 2 part tutorial plus YouTube video

• ReactiveCocoa at github.- Read the documentation folder

• Ash Furrow’s blog - teehan+lax

• Ash Furrow’s book - Functional Reactive Programming on iOS (Lean Pub)

• Warning: Some blogs and Stackoverflow posts are based on older versions of RAC. Make sure it refers to 2.x