---------------------------- --------------------------
| SignalProducerObservable | ← | SignalProducerProtocol |
---------------------------- --------------------------
↑ ↑
--------------------------- ------------------
| FinalizedSignalProducer | | SignalProducer |
--------------------------- ------------------
/// A relay of `AnyProperty`, enforcing the consistent order of `value` and signal | |
/// events. | |
final private class AnyPropertyRelay<Value> { | |
let atomicBox: Atomic<Value?> | |
let disposable: CompositeDisposable | |
let (relaySignal, relayObserver) = Signal<Value, NoError>.pipe() | |
var value: Value { | |
return atomicBox.value! | |
} |
public protocol PropertyDescribing { | |
/// The type or metatype the property belongs to. | |
associatedtype Container | |
/// The expected static type. | |
associatedtype Content | |
/// The name of the property. | |
var name: String { get } | |
diff --git a/ReactiveCocoa/Swift/Signal.swift b/ReactiveCocoa/Swift/Signal.swift | |
index 5e628eb..17b0d96 100644 | |
--- a/ReactiveCocoa/Swift/Signal.swift | |
+++ b/ReactiveCocoa/Swift/Signal.swift | |
@@ -84,11 +84,7 @@ public final class Signal<Value, Error: ErrorType> { | |
} | |
deinit { | |
- atomicObservers.withValue { observers in | |
- if let observers = observers where observers.isEmpty { |
class Atomic<Value> { | |
/// ... | |
/// Atomically modifies the variable. | |
/// | |
/// Returns the old value. | |
public func modify(@noescape action: (inout Value) throws -> Void) rethrows -> Value { | |
return try withValue { value in | |
try action(&_value) | |
return value |
struct LargeStruct { | |
var a: Int = 0 | |
var b: Int = 1 | |
var c: Int = 2 | |
var d: Int = 3 | |
var e: Int = 4 | |
var f: Int = 5 | |
var g: Int = 6 | |
var h: Int = 7 |
startWith*
was a compromise made in ReactiveCocoa 4.0 as a means to provide disambiguated, trailing closure compatible shorthands to start
. While they have been serving the community well since then, the community of Swift has established a new set of API guidelines for Swift. It specifically asks for API designs to look as grammatical as possible at the call site.
startWith*
is probably the APIs with the largest impact in ReativeSwift. Unfortunately, it is grammatically incorrect in its use of preposition IMO. For example, let’s say we have a line producer.startWithNext { value in action(value) }
. At the call site, it is generally read as:
Start [a producer] with Next, and pipe the value into the action.
The problem here is that we do not start a producer with next events, values or errors, but for the next events, the values and the errors. We start it for receiving the values, for any po
import Result | |
import ReactiveCocoa | |
import Foundation | |
/*: | |
## Sandbox | |
A place where you can build your sand castles 🏖. | |
*/ | |
import XCPlayground |
// View model for each tweets. | |
class TweetViewModel { | |
let username: AnyProperty<String> | |
let content: AnyProperty<String> | |
let date: AnyProperty<String> | |
init(tweet: tweet, controller: controller) { | |
let dateFormatter = { … } | |
username = AnyProperty(tweet.property(forKeyPath: #keyPath(Tweet.name))) | |
content = AnyProperty(tweet.property(forKeyPath: #keyPath(Tweet.content))) |
// | |
// BenchmarksTests.swift | |
// BenchmarksTests | |
// | |
// Created by Anders on 23/7/2016. | |
// Copyright © 2016 Anders. All rights reserved. | |
// | |
import XCTest | |
import Foundation |