Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Sources/Atomic.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ internal protocol AtomicStateProtocol {
///
/// - parameters:
/// - expected: The expected state.
/// - next: The state to transition to.
///
/// - returns:
/// `true` if the transition succeeds. `false` otherwise.
Expand Down Expand Up @@ -69,6 +70,7 @@ internal struct UnsafeAtomicState<State: RawRepresentable>: AtomicStateProtocol
///
/// - parameters:
/// - expected: The expected state.
/// - next: The state to transition to.
///
/// - returns:
/// `true` if the transition succeeds. `false` otherwise.
Expand Down
5 changes: 4 additions & 1 deletion Sources/Disposable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,10 @@ public final class CompositeDisposable: Disposable {
private var state: UnsafeAtomicState<DisposableState>

/// Represents a handle to a disposable previously added to a
/// CompositeDisposable.
/// `CompositeDisposable`.
///
/// - note: `add(_:)` method of `CompositeDisposable` creates instances of
/// `DisposableHandle`.
public final class DisposableHandle {
private var state: UnsafeAtomicState<DisposableState>
private var bagToken: RemovalToken?
Expand Down
266 changes: 224 additions & 42 deletions Sources/Flatten.swift

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions Sources/Lifetime.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import enum Result.NoError
/// Represents the lifetime of an object, and provides a hook to observe when
/// the object deinitializes.
public final class Lifetime {
/// MARK: Type properties and methods
// MARK: Type properties and methods

/// Factory method for creating a `Lifetime` and its associated `Token`.
///
/// - returns: A `(lifetime, token)` tuple.
public static func make() -> (lifetime: Lifetime, token: Token) {
let token = Token()
return (Lifetime(token), token)
Expand All @@ -17,15 +19,15 @@ public final class Lifetime {
return Lifetime(ended: .empty)
}

/// MARK: Instance properties
// MARK: Instance properties

/// A signal that sends a `completed` event when the lifetime ends.
///
/// - note: Consider using `Lifetime.observeEnded` if only a closure observer
/// is to be attached.
public let ended: Signal<(), NoError>

/// MARK: Initializers
// MARK: Initializers

/// Initialize a `Lifetime` object with the supplied ended signal.
///
Expand Down
6 changes: 6 additions & 0 deletions Sources/Property.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ public protocol PropertyProtocol: class, BindingSource {
}

extension PropertyProtocol {
/// Observe the property by sending all of future value changes to the
/// given `observer` during the given `lifetime`.
///
/// - parameters:
/// - observer: An observer to send the events to.
/// - lifetime: A lifetime of the observing object.
@discardableResult
public func observe(_ observer: Observer<Value, NoError>, during lifetime: Lifetime) -> Disposable? {
return producer.observe(observer, during: lifetime)
Expand Down
8 changes: 4 additions & 4 deletions Sources/Reactive.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ public struct Reactive<Base> {
/// The `Base` instance the extensions would be invoked with.
public let base: Base

// Construct a proxy.
//
// - parameters:
// - base: The object to be proxied.
/// Construct a proxy
///
/// - parameters:
/// - base: The object to be proxied.
fileprivate init(_ base: Base) {
self.base = base
}
Expand Down
5 changes: 5 additions & 0 deletions Sources/Scheduler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,9 @@ public final class QueueScheduler: DateScheduler {
/// Schedules a recurring action at the given interval with provided leeway,
/// beginning at the given start time.
///
/// - precondition: `interval` must be non-negative number.
/// - precondition: `leeway` must be non-negative number.
///
/// - parameters:
/// - date: A date to schedule the first action for.
/// - interval: A repetition interval.
Expand Down Expand Up @@ -427,6 +430,8 @@ public final class TestScheduler: DateScheduler {
/// Schedules a recurring action at the given interval, beginning at the
/// given start date.
///
/// - precondition: `interval` must be non-negative.
///
/// - parameters:
/// - date: A date to schedule the first action for.
/// - interval: A repetition interval.
Expand Down
10 changes: 10 additions & 0 deletions Sources/Signal.swift
Original file line number Diff line number Diff line change
Expand Up @@ -974,6 +974,8 @@ extension SignalProtocol {
/// - note: failed and `interrupted` events are always scheduled
/// immediately.
///
/// - precondition: `interval` must be non-negative number.
///
/// - parameters:
/// - interval: Interval to delay `value` and `completed` events by.
/// - scheduler: A scheduler to deliver delayed events on.
Expand Down Expand Up @@ -1003,6 +1005,8 @@ extension SignalProtocol {

/// Skip first `count` number of values then act as usual.
///
/// - precondition: `count` must be non-negative number.
///
/// - parameters:
/// - count: A number of values to skip.
///
Expand Down Expand Up @@ -1739,6 +1743,8 @@ extension SignalProtocol {
/// a value is being throttled, and if there is a new value sent,
/// the new value will be passed anyway.
///
/// - precondition: `interval` must be non-negative number.
///
/// - parameters:
/// - interval: Number of seconds to wait between sent values.
/// - scheduler: A scheduler to deliver events on.
Expand Down Expand Up @@ -1913,6 +1919,8 @@ extension SignalProtocol {
/// that value will be discarded and the returned signal will
/// terminate immediately.
///
/// - precondition: `interval` must be non-negative number.
///
/// - parameters:
/// - interval: A number of seconds to wait before sending a value.
/// - scheduler: A scheduler to send values on.
Expand Down Expand Up @@ -2193,6 +2201,8 @@ extension SignalProtocol {
/// The signal must complete synchronously (or on a faster
/// scheduler) to avoid the timeout.
///
/// - precondition: `interval` must be non-negative number.
///
/// - parameters:
/// - error: Error to send with failed event if `self` is not completed
/// when `interval` passes.
Expand Down
10 changes: 6 additions & 4 deletions Sources/SignalProducer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ extension SignalProducerProtocol {

/// Yield an array of values until it reaches a certain count.
///
/// - precondition: `count` should be greater than zero.
/// - precondition: `count` must be greater than zero.
///
/// - note: When the count is reached the array is sent and the signal
/// starts over yielding a new array of values.
Expand Down Expand Up @@ -1682,6 +1682,8 @@ extension SignalProducerProtocol {
/// - note: Repeating `0` times results in a producer that instantly
/// completes.
///
/// - precondition: `count` must be non-negative integer.
///
/// - parameters:
/// - count: Number of repetitions.
///
Expand Down Expand Up @@ -2137,7 +2139,7 @@ private struct ReplayState<Value, Error: Swift.Error> {
/// - note: This timer will never complete naturally, so all invocations of
/// `start()` must be disposed to avoid leaks.
///
/// - precondition: Interval must be non-negative number.
/// - precondition: `interval` must be non-negative number.
///
/// - note: If you plan to specify an `interval` value greater than 200,000
/// seconds, use `timer(interval:on:leeway:)` instead
Expand All @@ -2160,9 +2162,9 @@ public func timer(interval: DispatchTimeInterval, on scheduler: DateScheduler) -
/// - note: This timer will never complete naturally, so all invocations of
/// `start()` must be disposed to avoid leaks.
///
/// - precondition: Interval must be non-negative number.
/// - precondition: `interval` must be non-negative number.
///
/// - precondition: Leeway must be non-negative number.
/// - precondition: `leeway` must be non-negative number.
///
/// - parameters:
/// - interval: An interval between invocations.
Expand Down