Skip to content

Commit cde51c2

Browse files
committed
Example: RxSwift.
1 parent 13229e4 commit cde51c2

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

Package.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,12 @@ let package = Package(
1212
)
1313
],
1414
dependencies: [
15-
//example:
16-
// .package(url: "https://github.com/ReactiveX/RxSwift.git", "4.0.0" ..< "5.0.0")
15+
.package(url: "https://github.com/ReactiveX/RxSwift.git", "4.0.0" ..< "5.0.0")
1716
],
1817
targets: [
1918
.target(
2019
name: "STSLibrary",
21-
dependencies: []),
20+
dependencies: ["RxSwift"]),
2221
.target(
2322
name: "STSApplication",
2423
dependencies: ["STSLibrary"]),

Sources/STSLibrary/Application.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,7 @@ public final class Application {
77

88
public func run() throws {
99
print("\(prefix): \(TensorFlowExample.multiplyTensor())")
10+
print("\(prefix): Running RxExample:")
11+
RxExample.printHello()
1012
}
1113
}

Sources/STSLibrary/RxExample.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
import RxSwift
3+
import Foundation
4+
5+
struct RxExample {
6+
static func printHello() {
7+
let wordList = ["Hello", "Rx", "World"]
8+
9+
_ = Observable<Int>.interval(1, scheduler: SerialDispatchQueueScheduler(qos: .default))
10+
.take(wordList.count)
11+
.map { index in wordList[index]}
12+
.do(onNext: { word in
13+
print(word)
14+
})
15+
16+
// sleep for the duration of the above so the application doesn't exit before completion
17+
Thread.sleep(forTimeInterval: Double(wordList.count))
18+
}
19+
}

0 commit comments

Comments
 (0)