Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change inputs type to AnyObserver<Input> #193

Merged
merged 5 commits into from
Apr 23, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions Action.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
@@ -24,7 +24,6 @@
3D730DEB1F674044008534D3 /* Button+Action.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D730DE81F673FD9008534D3 /* Button+Action.swift */; };
3DD965C01F5DC0E400C180FE /* Action.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1FCDDA821EAC3295006EB95B /* Action.framework */; };
3DD965C61F5DC2E100C180FE /* ActionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F0569F01DE288EB007E1D0D /* ActionTests.swift */; };
3DD965C81F5DC2E700C180FE /* InputSubjectTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA2861C91ED6A41700BB327A /* InputSubjectTests.swift */; };
3DD965DE1F5DF8C500C180FE /* BindToTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DD965DD1F5DF86B00C180FE /* BindToTests.swift */; };
3DD965DF1F5DF8C900C180FE /* NSButtonTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DD965DA1F5DF79800C180FE /* NSButtonTests.swift */; };
5ED520241E1EA199007621B9 /* BindToTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5ED520231E1EA199007621B9 /* BindToTests.swift */; };
@@ -72,10 +71,6 @@
C41E08EF2237D2700039D213 /* Action+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4DE00042229758700FB50AB /* Action+Extensions.swift */; };
C41E08F02237D2740039D213 /* Action+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4DE00042229758700FB50AB /* Action+Extensions.swift */; };
C4DE00052229758700FB50AB /* Action+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4DE00042229758700FB50AB /* Action+Extensions.swift */; };
CA2861C81ED6979400BB327A /* InputSubject.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA2861C71ED6979400BB327A /* InputSubject.swift */; };
CA2861CA1ED6A41700BB327A /* InputSubjectTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA2861C91ED6A41700BB327A /* InputSubjectTests.swift */; };
CA2861CB1ED6B08300BB327A /* InputSubject.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA2861C71ED6979400BB327A /* InputSubject.swift */; };
CA2861CC1ED6B08400BB327A /* InputSubject.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA2861C71ED6979400BB327A /* InputSubject.swift */; };
FA3F973C1EDAF46F00A84787 /* Action.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F0569E21DE28587007E1D0D /* Action.swift */; };
FA3F973D1EDAF46F00A84787 /* Action+Internal.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F0569E01DE28587007E1D0D /* Action+Internal.swift */; };
FA3F973E1EDAF46F00A84787 /* InputSubject.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA2861C71ED6979400BB327A /* InputSubject.swift */; };
@@ -168,8 +163,6 @@
C4E0264220D11A3B00C8164C /* Readme.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = Readme.md; sourceTree = "<group>"; };
C4E0264320D11CDD00C8164C /* circle.yml */ = {isa = PBXFileReference; lastKnownFileType = text; path = circle.yml; sourceTree = "<group>"; };
C4E0264420D1244900C8164C /* Changelog.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = Changelog.md; sourceTree = "<group>"; };
CA2861C71ED6979400BB327A /* InputSubject.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InputSubject.swift; sourceTree = "<group>"; };
CA2861C91ED6A41700BB327A /* InputSubjectTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InputSubjectTests.swift; sourceTree = "<group>"; };
FC9C4166215A99BE00541C4B /* RxCocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = RxCocoa.framework; path = Carthage/Build/iOS/RxCocoa.framework; sourceTree = "<group>"; };
FC9C4167215A99BE00541C4B /* RxSwift.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = RxSwift.framework; path = Carthage/Build/iOS/RxSwift.framework; sourceTree = "<group>"; };
/* End PBXFileReference section */
@@ -295,7 +288,6 @@
7F0569E21DE28587007E1D0D /* Action.swift */,
C4DE00042229758700FB50AB /* Action+Extensions.swift */,
7F0569E01DE28587007E1D0D /* Action+Internal.swift */,
CA2861C71ED6979400BB327A /* InputSubject.swift */,
3D730DE11F673BCB008534D3 /* CommonUI */,
7F0569E41DE28587007E1D0D /* UIKitExtensions */,
7F0569EF1DE28598007E1D0D /* Supporting Files */,
@@ -352,7 +344,6 @@
3DD965DC1F5DF84800C180FE /* macOS-Tests */,
3DD965DB1F5DF83700C180FE /* iOS-Tests */,
7F0569F01DE288EB007E1D0D /* ActionTests.swift */,
CA2861C91ED6A41700BB327A /* InputSubjectTests.swift */,
7F0569F41DE288EB007E1D0D /* Info.plist */,
);
path = Tests;
@@ -723,7 +714,6 @@
C41E08EE2237D26D0039D213 /* Action+Extensions.swift in Sources */,
3D730DEA1F674043008534D3 /* Button+Action.swift in Sources */,
1FCDDA671EAC31EF006EB95B /* UIBarButtonItem+Action.swift in Sources */,
CA2861CB1ED6B08300BB327A /* InputSubject.swift in Sources */,
3D730DE41F673C64008534D3 /* Control+Action.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
@@ -732,7 +722,6 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
CA2861CC1ED6B08400BB327A /* InputSubject.swift in Sources */,
C41E08EF2237D2700039D213 /* Action+Extensions.swift in Sources */,
3D730DE51F673C65008534D3 /* Control+Action.swift in Sources */,
1FCDDA8A1EAC329E006EB95B /* Action.swift in Sources */,
@@ -747,7 +736,6 @@
files = (
FA3F973C1EDAF46F00A84787 /* Action.swift in Sources */,
FA3F973D1EDAF46F00A84787 /* Action+Internal.swift in Sources */,
FA3F973E1EDAF46F00A84787 /* InputSubject.swift in Sources */,
C41E08F02237D2740039D213 /* Action+Extensions.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
@@ -759,7 +747,6 @@
3DD965DE1F5DF8C500C180FE /* BindToTests.swift in Sources */,
3DD965C61F5DC2E100C180FE /* ActionTests.swift in Sources */,
3DD965DF1F5DF8C900C180FE /* NSButtonTests.swift in Sources */,
3DD965C81F5DC2E700C180FE /* InputSubjectTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -773,7 +760,6 @@
7F0569F51DE288EB007E1D0D /* ActionTests.swift in Sources */,
7B4BFE6320C290BF00D72FB0 /* RefreshControlTests.swift in Sources */,
7F0569F81DE288EB007E1D0D /* ButtonTests.swift in Sources */,
CA2861CA1ED6A41700BB327A /* InputSubjectTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -796,7 +782,6 @@
7F0569ED1DE28587007E1D0D /* UIBarButtonItem+Action.swift in Sources */,
C4DE00052229758700FB50AB /* Action+Extensions.swift in Sources */,
3D730DE91F673FD9008534D3 /* Button+Action.swift in Sources */,
CA2861C81ED6979400BB327A /* InputSubject.swift in Sources */,
3D730DE31F673BE4008534D3 /* Control+Action.swift in Sources */,
7F0569EA1DE28587007E1D0D /* Action.swift in Sources */,
);
6 changes: 4 additions & 2 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -15,11 +15,13 @@ Current master
- `enabled` ~> `isEnabled`
- `executing` ~> `isExecuting`
- Deprecate renamed properties
- Change `inputs` type to `AnyObserver<Input>`
bobgodwinx marked this conversation as resolved.
Show resolved Hide resolved

=======
3.11.0
-------
- Introduction of `underlyingError` observable which returns a `Swift.Error` element type.
- Updated specs that were breaking in `Circle CI` pipeline
- Introduction of `underlyingError` observable which returns a `Swift.Error` element type.
- Updated specs that were breaking in `Circle CI` pipeline

3.10.2
-------
16 changes: 10 additions & 6 deletions Sources/Action/Action.swift
Original file line number Diff line number Diff line change
@@ -22,11 +22,9 @@ When this excuted via execute() or inputs subject, it passes its parameter to th
public final class Action<Input, Element> {
public typealias WorkFactory = (Input) -> Observable<Element>

/// Inputs that triggers execution of action.
/// This subject also includes inputs as aguments of execute().
/// All inputs are always appear in this subject even if the action is not enabled.
/// Thus, inputs count equals elements count + errors count.
public let inputs = InputSubject<Input>()

/// Bindable sink for inputs that triggers execution of action.
public let inputs: AnyObserver<Input>

/// Errors aggrevated from invocations of execute().
/// Delivered on whatever scheduler they were sent from.
@@ -70,7 +68,13 @@ public final class Action<Input, Element> {
let errorsSubject = PublishSubject<ActionError>()
errors = errorsSubject.asObservable()

executionObservables = inputs
let inputsSubject = PublishSubject<Input>()
inputs = AnyObserver { event in
guard case .next(let value) = event else { return }
inputsSubject.onNext(value)
}

executionObservables = inputsSubject
.withLatestFrom(isEnabled) { input, enabled in (input, enabled) }
.flatMap { input, enabled -> Observable<Observable<Element>> in
if enabled {
93 changes: 0 additions & 93 deletions Sources/Action/InputSubject.swift

This file was deleted.

Loading