Skip to content

Commit

Permalink
Fix compilation errors for swift 5.2
Browse files Browse the repository at this point in the history
  • Loading branch information
niil-ohlin committed Mar 25, 2020
1 parent 395df83 commit f758a36
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Flow/CoreSignal.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public final class CoreSignal<Kind: SignalKind, Value> {
public typealias Event = Flow.Event<Value>
typealias EventType = Flow.EventType<Value>

internal init(onEventType: @escaping (@escaping (EventType) -> Void) -> Disposable, _ noTrailingClosure: Void = ()) {
internal init(onEventType: @escaping (@escaping (EventType) -> Void) -> Disposable) {
self.onEventType = onEventType
}
}
Expand Down
4 changes: 2 additions & 2 deletions Flow/Signal+Scheduling.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public extension CoreSignal where Kind == Plain, Value == () {
/// - Parameter delay: If provided will delay the first event by `delay`. If nil (default), `interval` will be used as the delay.
convenience init(every interval: TimeInterval, delay: TimeInterval? = nil) {
precondition(interval >= 0)
self.init { callback in
self.init(onValue: { callback in
let bag = DisposeBag()
guard interval.isFinite else { return bag }

Expand All @@ -93,7 +93,7 @@ public extension CoreSignal where Kind == Plain, Value == () {
timer.resume()

return bag
}
})
}

/// Creates a new signal that will signal once after `delay` seconds. Shorter version of `Signal(just: ()).delay(by: ...)`
Expand Down
4 changes: 2 additions & 2 deletions Flow/Signal+Transforms.swift
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ public extension SignalProvider {
/// - Note: At most one value is hold at a time and released when `readSignal` becomes true.
func wait(until readSignal: ReadSignal<Bool>) -> Signal<Value> {
let signal = providedSignal
return Signal { callback in
return Signal(onValue: { callback in
let state = StateAndCallback(state: Value?.none, callback: callback)

state += signal.filter(on: .none) { _ in !readSignal.value }.onValue {
Expand All @@ -672,7 +672,7 @@ public extension SignalProvider {
}.atValue(on: .none) { _ in state.protectedVal = nil }.onValue(on: .none, state.callback)

return state
}
})
}
}

Expand Down
4 changes: 2 additions & 2 deletions Flow/Signal+Utilities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import Foundation
public extension NotificationCenter {
/// Returns a signal for notifications named `name`.
func signal(forName name: Notification.Name?, object: Any? = nil) -> Signal<Notification> {
return Signal { callback in
return Signal(onValue: { callback in
let observer = self.addObserver(forName: name, object: object, queue: nil, using: callback)
return Disposer {
self.removeObserver(observer)
}
}
})
}
}

Expand Down
8 changes: 4 additions & 4 deletions FlowTests/SignalProviderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1135,10 +1135,10 @@ class SignalProviderTests: XCTestCase {
func testSharedSignal() {
let callbacker = Callbacker<Int>()
var s1 = 0
let s = Signal<Int> { c in
let s = Signal<Int>(onValue: { c in
s1 += 1
return callbacker.addCallback(c)
}
})

var s2 = 0
var s3 = 0
Expand Down Expand Up @@ -1179,10 +1179,10 @@ class SignalProviderTests: XCTestCase {
func testSharedRemoveAndAdd() {
let callbacker = Callbacker<Int>()
var s0 = 0
let s = Signal<Int> { c in
let s = Signal<Int>(onValue: { c in
s0 += 1
return callbacker.addCallback(c)
}
})

var s1 = 0
var s2 = 0
Expand Down

0 comments on commit f758a36

Please sign in to comment.