Skip to content
This repository has been archived by the owner on Jan 24, 2023. It is now read-only.

Commit

Permalink
Merge pull request #30 from UrbanCompass/replay-fixes
Browse files Browse the repository at this point in the history
Dont queue up done or error events
  • Loading branch information
russellbstephens authored Dec 13, 2016
2 parents 2144a53 + 1917362 commit fe9e323
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Snail/Replay.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ public class Replay<T>: Observable<T> {
}

public override func on(_ event: Event<E>) {
events.append(event)
events = Array(events.suffix(threshold))
if case .next(_) = event {
events.append(event)
events = Array(events.suffix(threshold))
}
super.on(event)
}

Expand Down
1 change: 1 addition & 0 deletions SnailTests/ReplayTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class ReplayTests: XCTestCase {
var strings: [String] = []
subject?.on(.next("1"))
subject?.on(.next("2"))
subject?.on(.done)
subject?
.subscribe(onNext: { string in strings.append(string) })
XCTAssert(strings[0] == "1")
Expand Down

0 comments on commit fe9e323

Please sign in to comment.