Skip to content

Commit

Permalink
Merge pull request #130 from neilpa/bump4.2.1
Browse files Browse the repository at this point in the history
RAC bump 4.2.1
  • Loading branch information
neilpa authored Jun 30, 2016
2 parents c14d2df + 8440488 commit 265e8e9
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 81 deletions.
2 changes: 1 addition & 1 deletion Cartfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "ReactiveCocoa/ReactiveCocoa" ~> 4.2
github "ReactiveCocoa/ReactiveCocoa" ~> 4.2.1
4 changes: 2 additions & 2 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github "antitypical/Result" "2.0.0"
github "ReactiveCocoa/ReactiveCocoa" "v4.2.0"
github "antitypical/Result" "2.1.1"
github "ReactiveCocoa/ReactiveCocoa" "v4.2.1"
17 changes: 1 addition & 16 deletions Source/Signal.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,22 +77,7 @@ extension SignalType {
return disposable
}
}

/// Enforces that at least `interval` time passes before forwarding a value. If a
/// new value arrives, the previous one is dropped and the `interval` delay starts
/// again. Error events are immediately forwarded, even if there's a queued value.
///
/// This operator is useful for scenarios like type-to-search where you want to
/// wait for a "lull" in typing before kicking off a search request.
@warn_unused_result(message="Did you forget to call `observe` on the signal?")
public func debounce(interval: NSTimeInterval, onScheduler scheduler: DateSchedulerType) -> Signal<Value, Error> {
precondition(interval >= 0)

return flatMap(.Latest) {
SignalProducer(value: $0).delay(interval, onScheduler: scheduler)
}
}


/// Forwards a value and then mutes the signal by dropping all subsequent values
/// for `interval` seconds. Once time elapses the next new value will be forwarded
/// and repeat the muting process. Error events are immediately forwarded even while
Expand Down
11 changes: 0 additions & 11 deletions Source/SignalProducer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,6 @@ extension SignalProducerType {
return lift { $0.timeoutAfter(interval, withEvent: event, onScheduler: scheduler) }
}

/// Enforces that at least `interval` time passes before forwarding a value. If a
/// new value arrives, the previous one is dropped and the `interval` delay starts
/// again. Error events are immediately forwarded, even if there's a queued value.
///
/// This operator is useful for scenarios like type-to-search where you want to
/// wait for a "lull" in typing before kicking off a search request.
@warn_unused_result(message="Did you forget to call `start` on the producer?")
public func debounce(interval: NSTimeInterval, onScheduler scheduler: DateSchedulerType) -> SignalProducer<Value, Error> {
return lift { $0.debounce(interval, onScheduler: scheduler) }
}

/// Forwards a value and then mutes the producer by dropping all subsequent values
/// for `interval` seconds. Once time elapses the next new value will be forwarded
/// and repeat the muting process. Error events are immediately forwarded even while
Expand Down
51 changes: 0 additions & 51 deletions Tests/SignalTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -130,57 +130,6 @@ final class SignalTests: XCTestCase {
XCTAssert(values == [1, 2, 3])
}

func testDebounceValues() {
let scheduler = TestScheduler()
let (signal, observer) = Signal<Int, NoError>.pipe()
var value = -1

signal
.debounce(1, onScheduler: scheduler)
.observeNext { value = $0 }

scheduler.schedule { observer.sendNext(1) }
scheduler.advance()
XCTAssertEqual(value, -1)

scheduler.advanceByInterval(1)
XCTAssertEqual(value, 1)

scheduler.schedule { observer.sendNext(2) }
scheduler.advance()
XCTAssertEqual(value, 1)

scheduler.schedule { observer.sendNext(3) }
scheduler.advance()
XCTAssertEqual(value, 1)

scheduler.advanceByInterval(1)
XCTAssertEqual(value, 3)
}

func testDebounceFailure() {
let scheduler = TestScheduler()
let (signal, observer) = Signal<Int, TestError>.pipe()
var value = -1
var failed = false

signal
.debounce(1, onScheduler: scheduler)
.observe(Observer(
next: { value = $0 },
failed: { _ in failed = true }
))

scheduler.schedule { observer.sendNext(1) }
scheduler.advance()
XCTAssertEqual(value, -1)

scheduler.schedule { observer.sendFailed(.Default) }
scheduler.advance()
XCTAssertTrue(failed)
XCTAssertEqual(value, -1)
}

func testMuteForValues() {
let scheduler = TestScheduler()
let (signal, observer) = Signal<Int, NoError>.pipe()
Expand Down

0 comments on commit 265e8e9

Please sign in to comment.