Skip to content

Commit 18b4094

Browse files
committed
Update demo app
1 parent cad5fc7 commit 18b4094

File tree

6 files changed

+18
-65
lines changed

6 files changed

+18
-65
lines changed

Documentation/RxGRDBDemo/RxGRDBDemo.xcodeproj/project.pbxproj

-14
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,10 @@
1515
565BD7D022C49D2100BB9B5A /* PlayersViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 565BD7CF22C49D2100BB9B5A /* PlayersViewModelTests.swift */; };
1616
565BD7D122C49D9800BB9B5A /* PlayersViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 567515A722C3B1F100A6FF66 /* PlayersViewModel.swift */; };
1717
565BD7D222C49E6600BB9B5A /* World.swift in Sources */ = {isa = PBXBuildFile; fileRef = 567515A122C3A7DC00A6FF66 /* World.swift */; };
18-
565BD7D322C49EAA00BB9B5A /* Action+App.swift in Sources */ = {isa = PBXBuildFile; fileRef = 567515AA22C3CDAC00A6FF66 /* Action+App.swift */; };
1918
565BD7D922C5DEE800BB9B5A /* PlayerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 565BD7D822C5DEE800BB9B5A /* PlayerTests.swift */; };
2019
567515A222C3A7DC00A6FF66 /* World.swift in Sources */ = {isa = PBXBuildFile; fileRef = 567515A122C3A7DC00A6FF66 /* World.swift */; };
2120
567515A422C3A9BC00A6FF66 /* Players.swift in Sources */ = {isa = PBXBuildFile; fileRef = 567515A322C3A9BC00A6FF66 /* Players.swift */; };
2221
567515A822C3B1F100A6FF66 /* PlayersViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 567515A722C3B1F100A6FF66 /* PlayersViewModel.swift */; };
23-
567515AB22C3CDAC00A6FF66 /* Action+App.swift in Sources */ = {isa = PBXBuildFile; fileRef = 567515AA22C3CDAC00A6FF66 /* Action+App.swift */; };
2422
567E66D02438A6F80091B5D8 /* RxGRDB in Frameworks */ = {isa = PBXBuildFile; productRef = 567E66CF2438A6F80091B5D8 /* RxGRDB */; };
2523
56D6EA2F2438AB77000D55EF /* RxSwift in Frameworks */ = {isa = PBXBuildFile; productRef = 56D6EA2E2438AB77000D55EF /* RxSwift */; };
2624
56D6EA322438ABAE000D55EF /* RxDataSources in Frameworks */ = {isa = PBXBuildFile; productRef = 56D6EA312438ABAE000D55EF /* RxDataSources */; };
@@ -73,7 +71,6 @@
7371
567515A122C3A7DC00A6FF66 /* World.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = World.swift; sourceTree = "<group>"; };
7472
567515A322C3A9BC00A6FF66 /* Players.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Players.swift; sourceTree = "<group>"; };
7573
567515A722C3B1F100A6FF66 /* PlayersViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayersViewModel.swift; sourceTree = "<group>"; };
76-
567515AA22C3CDAC00A6FF66 /* Action+App.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Action+App.swift"; sourceTree = "<group>"; };
7774
567E66CD2438A6730091B5D8 /* RxGRDB */ = {isa = PBXFileReference; lastKnownFileType = folder; name = RxGRDB; path = ../..; sourceTree = "<group>"; };
7875
56E1F9791F8101EE00793BFA /* RxGRDBDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = RxGRDBDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
7976
56E1F97C1F8101EE00793BFA /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
@@ -154,14 +151,6 @@
154151
path = Resources;
155152
sourceTree = "<group>";
156153
};
157-
567515A922C3CD9B00A6FF66 /* Utils */ = {
158-
isa = PBXGroup;
159-
children = (
160-
567515AA22C3CDAC00A6FF66 /* Action+App.swift */,
161-
);
162-
path = Utils;
163-
sourceTree = "<group>";
164-
};
165154
567E66CE2438A6F80091B5D8 /* Frameworks */ = {
166155
isa = PBXGroup;
167156
children = (
@@ -198,7 +187,6 @@
198187
567515A122C3A7DC00A6FF66 /* World.swift */,
199188
5675159E22C3A77800A6FF66 /* Models */,
200189
5675159F22C3A7AE00A6FF66 /* UI */,
201-
567515A922C3CD9B00A6FF66 /* Utils */,
202190
567515A022C3A7BA00A6FF66 /* Resources */,
203191
);
204192
path = RxGRDBDemo;
@@ -332,7 +320,6 @@
332320
565BD7D122C49D9800BB9B5A /* PlayersViewModel.swift in Sources */,
333321
565BD7C922C3FA8B00BB9B5A /* PlayersTests.swift in Sources */,
334322
565BD7CA22C3FAA700BB9B5A /* Players.swift in Sources */,
335-
565BD7D322C49EAA00BB9B5A /* Action+App.swift in Sources */,
336323
565BD7C622C3F92F00BB9B5A /* AppDatabase.swift in Sources */,
337324
565BD7D022C49D2100BB9B5A /* PlayersViewModelTests.swift in Sources */,
338325
565BD7C722C3F97900BB9B5A /* Player.swift in Sources */,
@@ -351,7 +338,6 @@
351338
567515A822C3B1F100A6FF66 /* PlayersViewModel.swift in Sources */,
352339
56E1F97F1F8101EE00793BFA /* PlayersViewController.swift in Sources */,
353340
56E1F97D1F8101EE00793BFA /* AppDelegate.swift in Sources */,
354-
567515AB22C3CDAC00A6FF66 /* Action+App.swift in Sources */,
355341
567515A222C3A7DC00A6FF66 /* World.swift in Sources */,
356342
);
357343
runOnlyForDeploymentPostprocessing = 0;

Documentation/RxGRDBDemo/RxGRDBDemo.xcodeproj/xcshareddata/xcschemes/RxGRDBDemo.xcscheme

+9-13
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,15 @@
4141
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
4242
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
4343
shouldUseLaunchSchemeArgsEnv = "YES">
44+
<MacroExpansion>
45+
<BuildableReference
46+
BuildableIdentifier = "primary"
47+
BlueprintIdentifier = "56E1F9781F8101EE00793BFA"
48+
BuildableName = "RxGRDBDemo.app"
49+
BlueprintName = "RxGRDBDemo"
50+
ReferencedContainer = "container:RxGRDBDemo.xcodeproj">
51+
</BuildableReference>
52+
</MacroExpansion>
4453
<Testables>
4554
<TestableReference
4655
skipped = "NO">
@@ -53,17 +62,6 @@
5362
</BuildableReference>
5463
</TestableReference>
5564
</Testables>
56-
<MacroExpansion>
57-
<BuildableReference
58-
BuildableIdentifier = "primary"
59-
BlueprintIdentifier = "56E1F9781F8101EE00793BFA"
60-
BuildableName = "RxGRDBDemo.app"
61-
BlueprintName = "RxGRDBDemo"
62-
ReferencedContainer = "container:RxGRDBDemo.xcodeproj">
63-
</BuildableReference>
64-
</MacroExpansion>
65-
<AdditionalOptions>
66-
</AdditionalOptions>
6765
</TestAction>
6866
<LaunchAction
6967
buildConfiguration = "Debug"
@@ -85,8 +83,6 @@
8583
ReferencedContainer = "container:RxGRDBDemo.xcodeproj">
8684
</BuildableReference>
8785
</BuildableProductRunnable>
88-
<AdditionalOptions>
89-
</AdditionalOptions>
9086
</LaunchAction>
9187
<ProfileAction
9288
buildConfiguration = "Release"

Documentation/RxGRDBDemo/RxGRDBDemo/Models/Players.swift

+6-8
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,20 @@ struct Players {
1919
try database.write(_populateIfEmpty)
2020
}
2121

22-
func deleteAll() -> Completable {
22+
func deleteAll() -> Single<Void> {
2323
database.rx.write(updates: _deleteAll)
2424
}
2525

26-
func deleteOne(_ player: Player) -> Completable {
27-
database.rx.write(updates: { db in
28-
try self._deleteOne(db, player: player)
29-
})
26+
func deleteOne(_ player: Player) -> Single<Void> {
27+
database.rx.write(updates: { db in try self._deleteOne(db, player: player) })
3028
}
3129

32-
func refresh() -> Completable {
30+
func refresh() -> Single<Void> {
3331
database.rx.write(updates: _refresh)
3432
}
3533

36-
func stressTest() -> Completable {
37-
Completable.zip(repeatElement(refresh(), count: 50))
34+
func stressTest() -> Single<Void> {
35+
Single.zip(repeatElement(refresh(), count: 50)).map { _ in }
3836
}
3937

4038
// MARK: - Access Players

Documentation/RxGRDBDemo/RxGRDBDemo/UI/PlayersViewModel.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class PlayersViewModel {
6868
}
6969

7070
deleteOne = CompletableAction { player in
71-
Current.players().deleteOne(player)
71+
Current.players().deleteOne(player).asCompletable()
7272
}
7373

7474
refresh = CocoaAction {
@@ -79,14 +79,14 @@ class PlayersViewModel {
7979
Current.players().stressTest()
8080
}
8181

82-
toggleOrdering = CocoaAction { _ -> Completable in
82+
toggleOrdering = CocoaAction {
8383
switch ordering.value {
8484
case .byName:
8585
ordering.accept(.byScore)
8686
case .byScore:
8787
ordering.accept(.byName)
8888
}
89-
return .empty()
89+
return Observable.just(())
9090
}
9191
}
9292
}

Documentation/RxGRDBDemo/RxGRDBDemo/Utils/Action+App.swift

-14
This file was deleted.

TODO.md

-13
Original file line numberDiff line numberDiff line change
@@ -1,14 +1 @@
1-
- [ ] RxGRDB/Documentation/RxGRDBDemo/RxGRDBDemo/Models/Players.swift
21

3-
TODO GRDB: If we define the `database` property as AnyDatabaseWriter
4-
and erase the type in the initializer, we have a crash when the
5-
database changes and observations are triggered. Workaround: perform
6-
late type erasing.
7-
8-
TODO RxRGDB: We could avoid this churn by exposing observables
9-
without the `rx` joiner, directly on DatabaseWriter and
10-
DatabaseReader protocols, as in GRDBCombine.
11-
12-
- [ ] Expose a new observation mode that doesn't guarantee the notification of all changes, but can start immediately when one uses a DatabasePool. See https://github.com/groue/GRDB.swift/issues/601#issuecomment-524545056
13-
14-
- [ ] Optimization: cancel the initial fetch of a value observation, and its registration as a database observer, if the wrapping Observable has been cancelled. See https://github.com/groue/GRDB.swift/issues/601#issuecomment-524648244

0 commit comments

Comments
 (0)