Skip to content
This repository was archived by the owner on Aug 1, 2023. It is now read-only.

Commit 1c219c6

Browse files
committed
Using RxBlocking on tests
1 parent cb576bf commit 1c219c6

File tree

14 files changed

+293
-658
lines changed

14 files changed

+293
-658
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ install:
55
- ./install_dependencies.sh
66

77
script:
8-
- fastlane ci
8+
- bundle exec fastlane ci

Classes/RxWebSocket.swift

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ open class RxWebSocket: WebSocket {
3333
case data(Data)
3434
}
3535

36-
fileprivate let publishStream: PublishSubject<StreamEvent>
36+
fileprivate let connectSubject: ReplaySubject<StreamEvent>
37+
fileprivate let eventSubject: PublishSubject<StreamEvent>
3738

3839
/**
3940
- parameters:
@@ -47,15 +48,18 @@ open class RxWebSocket: WebSocket {
4748
*/
4849
override public init(request: URLRequest, protocols: [String]? = nil, stream: WSStream = FoundationStream()) {
4950
let publish = PublishSubject<StreamEvent>()
50-
publishStream = publish
51+
eventSubject = publish
52+
53+
let replay = ReplaySubject<StreamEvent>.create(bufferSize: 1)
54+
connectSubject = replay
5155

5256
super.init(request: request, protocols: protocols, stream: stream)
5357

54-
super.onConnect = { publish.onNext(.connect) }
55-
super.onDisconnect = { publish.onNext(.disconnect($0)) }
58+
super.onConnect = { replay.onNext(.connect) }
5659
super.onText = { publish.onNext(.text($0)) }
5760
super.onData = { publish.onNext(.data($0)) }
5861
super.onPong = { publish.onNext(.pong($0)) }
62+
super.onDisconnect = { replay.onNext(.disconnect($0)) }
5963

6064
connect()
6165
}
@@ -152,7 +156,7 @@ public extension Reactive where Base: RxWebSocket {
152156
}
153157

154158
/// The stream of messages received by the websocket.
155-
public var stream: Observable<RxWebSocket.StreamEvent> {
156-
return base.publishStream.asObservable()
159+
public var stream: Observable<Base.StreamEvent> {
160+
return Observable.merge(base.connectSubject, base.eventSubject)
157161
}
158162
}

Example/Podfile

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,4 @@ use_frameworks!
66

77
target 'RxWebSocket_Example' do
88
pod 'RxWebSocket', :path => '../'
9-
10-
pod 'SwiftLint', '~> 0.23.1'
11-
12-
target 'RxWebSocket_Tests' do
13-
inherit! :search_paths
14-
end
159
end

Example/Podfile.lock

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@ PODS:
77
- RxSwift (~> 4.0)
88
- Starscream (~> 3.0)
99
- Starscream (3.0.2)
10-
- SwiftLint (0.23.1)
1110

1211
DEPENDENCIES:
1312
- RxWebSocket (from `../`)
14-
- SwiftLint (~> 0.23.1)
1513

1614
EXTERNAL SOURCES:
1715
RxWebSocket:
@@ -22,8 +20,7 @@ SPEC CHECKSUMS:
2220
RxSwift: fd680d75283beb5e2559486f3c0ff852f0d35334
2321
RxWebSocket: 92e3b508c1edc110ae99db695c64c83326e2cf70
2422
Starscream: b512c62f6706421221b5ceb2ba01a9f58aca5bea
25-
SwiftLint: 1b670ce79284c76520f84060e87d645078fd32fa
2623

27-
PODFILE CHECKSUM: 456db7708e72ed614ed2493176db7ce5f5302def
24+
PODFILE CHECKSUM: 2856c9d589b1d945bedd888ba5283bf79d28af3b
2825

2926
COCOAPODS: 1.3.1

0 commit comments

Comments
 (0)