You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
__ReactiveSwift__ offers composable, declarative and flexible primitives that are built around the grand concept of ___streams of values over time___. These primitives can be used to uniformly represent common Cocoa and generic programming patterns that are fundamentally an act of observation, e.g.:
14
+
__ReactiveSwift__ offers composable, declarative and flexible primitives that are built around the grand concept of ___streams of values over time___.
13
15
14
-
* Delegate methods
15
-
* Callback blocks
16
-
* Notifications
17
-
* Control actions and responder chain events
18
-
*[Futures and promises](https://en.wikipedia.org/wiki/Futures_and_promises)
These primitives can be used to uniformly represent common Cocoa and generic programming patterns that are fundamentally an act of observation, e.g. delegate pattern, callback closures, notifications, control actions, responder chain events, [futures/promises](https://en.wikipedia.org/wiki/Futures_and_promises) and [key-value observing](https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/KeyValueObserving/KeyValueObserving.html) (KVO).
20
17
21
18
Because all of these different mechanisms can be represented in the _same_ way,
22
-
it’s easy to declaratively chain and combine them together, with less spaghetti
19
+
it’s easy to declaratively compose them together, with less spaghetti
23
20
code and state to bridge the gap.
24
21
25
-
For more information about the concepts in ReactiveSwift, see the [Framework
26
-
Overview][].
22
+
### Core Reactive Primitives
23
+
#### `Signal`: a unidirectional stream of events.
24
+
The owner of a `Signal` has unilateral control of the event stream. Observers may register their interests in the future events at any time, but the observation would have no side effect on the stream or its owner.
25
+
26
+
It is like a live TV feed — you can observe and react to the content, but you cannot have a side effect on the live feed or the TV station.
27
+
28
+
```swift
29
+
let channel: Signal<Program, NoError> = tvStation.channelOne
30
+
channel.observeValues { program in... }
31
+
```
32
+
33
+
#### `Event`: the basic transfer unit of an event stream.
34
+
A `Signal` may have any arbitrary number of events carrying a value, following by an eventual terminal event of a specific reason.
35
+
36
+
It is like a frame in a one-time live feed — seas of data frames carry the visual and audio data, but the feed would eventually be terminated with a special frame to indicate "end of stream".
37
+
38
+
#### `SignalProducer`: deferred work that creates a stream of values.
39
+
`SignalProducer` defers work — of which the output is represented as a stream of values — until it is started. For every invocation to start the `SignalProducer`, a new `Signal` is created and the deferred work is subsequently invoked.
40
+
41
+
It is like a on-demand streaming service — even though the episode is streamed like a live TV feed, you can choose what you watch, when to start watching and when to interrupt it.
42
+
43
+
44
+
```swift
45
+
let frames: SignalProducer<VideoFrame, ConnectionError> = vidStreamer.streamAsset(id: tvShowId)
46
+
let interrupter = frames.start { frame in... }
47
+
interrupter.dispose()
48
+
```
49
+
50
+
#### `Property`: an observable box that always holds a value.
51
+
`Property` is a variable that can be observed for its changes. In other words, it is a stream of values with a stronger guarantee than `Signal` — the latest value is always available, and the stream would never fail.
52
+
53
+
It is like the continuously updated current time offset of a video playback — the playback is always at a certain time offset at any time, and it would be updated by the playback logic as the playback continues.
54
+
55
+
```swift
56
+
let currentTime: Property<TimeInterval> = video.currentTime
57
+
print("Current time offset: \(currentTime.value)")
#### `Action`: a serialized worker with a preset action.
62
+
When being invoked with an input, `Action` apply the input and the latest state to the preset action, and pushes the output to any interested parties.
63
+
64
+
It is like an automatic vending machine — after choosing an option with coins inserted, the machine would process the order and eventually output your wanted snacks. Notice that the entire process is mutually exclusive — you cannot have the machine to serve two customers concurrently.
65
+
66
+
```swift
67
+
// Purchase from the vending machine with a specific option.
68
+
vendingMachine.purchase
69
+
.apply(snackId)
70
+
.startWithResults { result
71
+
switch results {
72
+
caselet .success(snacks):
73
+
print("Snack: \(snacks)")
74
+
75
+
caselet .failure(error):
76
+
// Out of stock? Insufficient fund?
77
+
print("Transaction aborted: \(error)")
78
+
}
79
+
}
80
+
81
+
// The vending machine.
82
+
classVendingMachine {
83
+
let purchase: Action<(), [Snack], VendingMachineError>
84
+
let coins: MutableProperty<Int>
85
+
86
+
// The vending machine is connected with a sales recorder.
If you use Carthage to build your dependencies, make sure you have added `ReactiveSwift.framework`, and `Result.framework` to the "_Linked Frameworks and Libraries_" section of your target, and have included them in your Carthage framework copying build phase.
@@ -289,7 +378,7 @@ If you use [CocoaPods][] to manage your dependencies, simply add
289
378
ReactiveSwift to your `Podfile`:
290
379
291
380
```
292
-
pod 'ReactiveSwift', '1.0.0-alpha.4'
381
+
pod 'ReactiveSwift', '1.0.0-rc.1'
293
382
```
294
383
295
384
#### Swift Package Manager
@@ -298,7 +387,7 @@ If you use Swift Package Manager, simply add ReactiveSwift as a dependency
@@ -332,9 +421,42 @@ We also provide a great Playground, so you can get used to ReactiveCocoa's opera
332
421
## Have a question?
333
422
If you need any help, please visit our [GitHub issues][] or [Stack Overflow][]. Feel free to file an issue if you do not manage to find any solution from the archives.
It targets Swift 3.0.x. The tentative schedule of a Gold Master release is January 2017.
429
+
430
+
A Release Candidate would be released after an important bug fix and an API renaming PR are cleared, which should happen no later than Christmas 2016.
431
+
432
+
A point release is expected with performance optimizations.
433
+
434
+
### Plan of Record
435
+
#### ReactiveSwift 2.0
436
+
It targets Swift 3.1.x. The estimated schedule is Spring 2017.
437
+
438
+
The release contains breaking changes. But they are not expected to affect the general mass of users, but only a few specific use cases.
439
+
440
+
The primary goal of ReactiveSwift 2.0 is to remove single-implementation protocols, e.g. `SignalProtocol`, `SignalProducerProtocol`, that serve as a workaround to **concrete same-type requirements**.
441
+
442
+
ReactiveSwift 2.0 may include other proposed breaking changes.
443
+
444
+
As resilience would be enforced in Swift 4.0, it is important for us to have a clean and steady API to start with. The expectation is to **have the API cleanup and the reviewing to be concluded in ReactiveSwift 2.0**, before we move on to ReactiveSwift 3.0 and Swift 4.0. Any contribution to help realising this goal is welcomed.
445
+
446
+
#### ReactiveSwift 3.0
447
+
It targets Swift 4.0.x. The estimated schedule is late 2017.
448
+
449
+
The release may contain breaking changes, depending on what features are being delivered by Swift 4.0.
450
+
451
+
ReactiveSwift 3.0 would focus on two main goals:
452
+
453
+
1. Swift 4.0 Resilience
454
+
2. Adapt to new features introduced in Swift 4.0 Phase 2.
0 commit comments