forked from ReactiveX/RxSwift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TestableObserver.swift
32 lines (26 loc) · 829 Bytes
/
TestableObserver.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
//
// TestableObserver.swift
// RxTest
//
// Created by Krunoslav Zaher on 2/15/15.
// Copyright © 2015 Krunoslav Zaher. All rights reserved.
//
import Foundation
import RxSwift
/// Observer that records events together with virtual time when they were received.
public class TestableObserver<ElementType>
: ObserverType {
public typealias Element = ElementType
fileprivate let _scheduler: TestScheduler
/// Recorded events.
public fileprivate(set) var events = [Recorded<Event<Element>>]()
init(scheduler: TestScheduler) {
_scheduler = scheduler
}
/// Notify observer about sequence event.
///
/// - parameter event: Event that occured.
public func on(_ event: Event<Element>) {
events.append(Recorded(time: _scheduler.clock, value: event))
}
}