Skip to content

Commit

Permalink
Added MainActorSharingStrategyProtocol to allow shared sequences whic…
Browse files Browse the repository at this point in the history
…h are not limited to the main actor.
  • Loading branch information
fabianmuecke committed Oct 28, 2024
1 parent 9cee95e commit 20a894b
Show file tree
Hide file tree
Showing 8 changed files with 642 additions and 96 deletions.
12 changes: 8 additions & 4 deletions Rx.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,6 @@
C89AB1DA1DAAC3350065FBE6 /* Driver.swift in Sources */ = {isa = PBXBuildFile; fileRef = C89AB1B11DAAC3350065FBE6 /* Driver.swift */; };
C89AB1DE1DAAC3350065FBE6 /* ObservableConvertibleType+Driver.swift in Sources */ = {isa = PBXBuildFile; fileRef = C89AB1B21DAAC3350065FBE6 /* ObservableConvertibleType+Driver.swift */; };
C89AB1EA1DAAC3350065FBE6 /* SharedSequence+Operators+arity.swift in Sources */ = {isa = PBXBuildFile; fileRef = C89AB1B61DAAC3350065FBE6 /* SharedSequence+Operators+arity.swift */; };
C89AB1F21DAAC3350065FBE6 /* SharedSequence+Operators.swift in Sources */ = {isa = PBXBuildFile; fileRef = C89AB1B81DAAC3350065FBE6 /* SharedSequence+Operators.swift */; };
C89AB1F61DAAC3350065FBE6 /* SharedSequence.swift in Sources */ = {isa = PBXBuildFile; fileRef = C89AB1B91DAAC3350065FBE6 /* SharedSequence.swift */; };
C89AB2021DAAC3350065FBE6 /* KVORepresentable+CoreGraphics.swift in Sources */ = {isa = PBXBuildFile; fileRef = C89AB1BD1DAAC3350065FBE6 /* KVORepresentable+CoreGraphics.swift */; };
C89AB2061DAAC3350065FBE6 /* KVORepresentable+Swift.swift in Sources */ = {isa = PBXBuildFile; fileRef = C89AB1BE1DAAC3350065FBE6 /* KVORepresentable+Swift.swift */; };
Expand Down Expand Up @@ -789,6 +788,8 @@
CB883B451BE256D4000AC2EE /* BooleanDisposable.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB883B441BE256D4000AC2EE /* BooleanDisposable.swift */; };
CD8F7AC527BA9187001574EB /* Infallible+Driver.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD8F7AC427BA9187001574EB /* Infallible+Driver.swift */; };
CDDEF16A1D4FB40000CA8546 /* Disposables.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDDEF1691D4FB40000CA8546 /* Disposables.swift */; };
D2B78EEC2CCF9F8B0054AB01 /* SharedSequence+Operators.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2B78EEB2CCF9F8B0054AB01 /* SharedSequence+Operators.swift */; };
D2B78EEE2CCF9FDD0054AB01 /* SharedSequence+Operators+MainActor.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2B78EED2CCF9FDD0054AB01 /* SharedSequence+Operators+MainActor.swift */; };
D9080ACF1EA05AE0002B433B /* RxNavigationControllerDelegateProxy.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9080ACD1EA05A16002B433B /* RxNavigationControllerDelegateProxy.swift */; };
D9080AD41EA05DE9002B433B /* UINavigationController+Rx.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9080AD21EA05DDF002B433B /* UINavigationController+Rx.swift */; };
D9080AD81EA06189002B433B /* UINavigationController+RxTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9080AD71EA06189002B433B /* UINavigationController+RxTests.swift */; };
Expand Down Expand Up @@ -1353,7 +1354,6 @@
C89AB1B21DAAC3350065FBE6 /* ObservableConvertibleType+Driver.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ObservableConvertibleType+Driver.swift"; sourceTree = "<group>"; };
C89AB1B61DAAC3350065FBE6 /* SharedSequence+Operators+arity.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "SharedSequence+Operators+arity.swift"; sourceTree = "<group>"; };
C89AB1B71DAAC3350065FBE6 /* SharedSequence+Operators+arity.tt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "SharedSequence+Operators+arity.tt"; sourceTree = "<group>"; };
C89AB1B81DAAC3350065FBE6 /* SharedSequence+Operators.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "SharedSequence+Operators.swift"; sourceTree = "<group>"; };
C89AB1B91DAAC3350065FBE6 /* SharedSequence.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SharedSequence.swift; sourceTree = "<group>"; };
C89AB1BD1DAAC3350065FBE6 /* KVORepresentable+CoreGraphics.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "KVORepresentable+CoreGraphics.swift"; sourceTree = "<group>"; };
C89AB1BE1DAAC3350065FBE6 /* KVORepresentable+Swift.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "KVORepresentable+Swift.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1453,6 +1453,8 @@
CB883B441BE256D4000AC2EE /* BooleanDisposable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BooleanDisposable.swift; sourceTree = "<group>"; };
CD8F7AC427BA9187001574EB /* Infallible+Driver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Infallible+Driver.swift"; sourceTree = "<group>"; };
CDDEF1691D4FB40000CA8546 /* Disposables.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Disposables.swift; sourceTree = "<group>"; };
D2B78EEB2CCF9F8B0054AB01 /* SharedSequence+Operators.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SharedSequence+Operators.swift"; sourceTree = "<group>"; };
D2B78EED2CCF9FDD0054AB01 /* SharedSequence+Operators+MainActor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SharedSequence+Operators+MainActor.swift"; sourceTree = "<group>"; };
D9080ACD1EA05A16002B433B /* RxNavigationControllerDelegateProxy.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RxNavigationControllerDelegateProxy.swift; sourceTree = "<group>"; };
D9080AD21EA05DDF002B433B /* UINavigationController+Rx.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UINavigationController+Rx.swift"; sourceTree = "<group>"; };
D9080AD71EA06189002B433B /* UINavigationController+RxTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UINavigationController+RxTests.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2346,7 +2348,8 @@
children = (
C89AB1B61DAAC3350065FBE6 /* SharedSequence+Operators+arity.swift */,
C89AB1B71DAAC3350065FBE6 /* SharedSequence+Operators+arity.tt */,
C89AB1B81DAAC3350065FBE6 /* SharedSequence+Operators.swift */,
D2B78EEB2CCF9F8B0054AB01 /* SharedSequence+Operators.swift */,
D2B78EED2CCF9FDD0054AB01 /* SharedSequence+Operators+MainActor.swift */,
DB08833626FB0637005805BE /* SharedSequence+Concurrency.swift */,
C89AB1B91DAAC3350065FBE6 /* SharedSequence.swift */,
C85E6FBD1F53025700C5681E /* SchedulerType+SharedSequence.swift */,
Expand Down Expand Up @@ -3045,6 +3048,7 @@
B562478F203515DD00D3EE75 /* RxCollectionViewDataSourcePrefetchingProxy.swift in Sources */,
84E4D3921C9AFD3400ADFDC9 /* UISearchController+Rx.swift in Sources */,
C88254341B8A752B00B02D69 /* UITableView+Rx.swift in Sources */,
D2B78EEC2CCF9F8B0054AB01 /* SharedSequence+Operators.swift in Sources */,
CD8F7AC527BA9187001574EB /* Infallible+Driver.swift in Sources */,
C89AB1A61DAAC25A0065FBE6 /* RxCocoaObjCRuntimeError+Extensions.swift in Sources */,
C88254161B8A752B00B02D69 /* RxCollectionViewReactiveArrayDataSource.swift in Sources */,
Expand Down Expand Up @@ -3080,7 +3084,6 @@
C89AB1CA1DAAC3350065FBE6 /* ControlProperty.swift in Sources */,
ECBBA59E1DF8C0D400DDDC2E /* RxTabBarControllerDelegateProxy.swift in Sources */,
78F2D93E24C8D35700D13F0C /* RxWKNavigationDelegateProxy.swift in Sources */,
C89AB1F21DAAC3350065FBE6 /* SharedSequence+Operators.swift in Sources */,
9BA1CBD31C0F7D550044B50A /* UIActivityIndicatorView+Rx.swift in Sources */,
842A5A2C1C357F92003568D5 /* NSTextStorage+Rx.swift in Sources */,
C88254241B8A752B00B02D69 /* RxTextViewDelegateProxy.swift in Sources */,
Expand All @@ -3098,6 +3101,7 @@
C89AB2501DAAC3A60065FBE6 /* _RXObjCRuntime.m in Sources */,
C89AB21E1DAAC3350065FBE6 /* NSObject+Rx.swift in Sources */,
D9080AD41EA05DE9002B433B /* UINavigationController+Rx.swift in Sources */,
D2B78EEE2CCF9FDD0054AB01 /* SharedSequence+Operators+MainActor.swift in Sources */,
88718CFE1CE5D80000D88D60 /* UITabBar+Rx.swift in Sources */,
88D98F2E1CE7549A00D50457 /* RxTabBarDelegateProxy.swift in Sources */,
C88254331B8A752B00B02D69 /* UISwitch+Rx.swift in Sources */,
Expand Down
2 changes: 1 addition & 1 deletion RxCocoa/Traits/Driver/Driver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import RxSwift
*/
public typealias Driver<Element> = SharedSequence<DriverSharingStrategy, Element>

public struct DriverSharingStrategy: SharingStrategyProtocol {
public struct DriverSharingStrategy: MainActorSharingStrategyProtocol {
public static var scheduler: SchedulerType { SharingScheduler.make() }
public static func share<Element>(_ source: Observable<Element>) -> Observable<Element> {
source.share(replay: 1, scope: .whileConnected)
Expand Down
Loading

0 comments on commit 20a894b

Please sign in to comment.