Skip to content

Commit

Permalink
Adds general form of feedback loop.
Browse files Browse the repository at this point in the history
  • Loading branch information
kzaher committed Jan 15, 2019
1 parent fef0d16 commit f0ef2c6
Show file tree
Hide file tree
Showing 15 changed files with 272 additions and 982 deletions.
4 changes: 0 additions & 4 deletions Examples/Examples.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 23,6 @@
C84645911EB775AF0008AD87 /* SystemError.swift in Sources */ = {isa = PBXBuildFile; fileRef = C84645901EB775AF0008AD87 /* SystemError.swift */; };
C84645931EB78D320008AD87 /* UILabel Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = C84645921EB78D320008AD87 /* UILabel Extensions.swift */; };
C84893732190FAE900561487 /* AsyncSynchronized.swift in Sources */ = {isa = PBXBuildFile; fileRef = C84893692190FAE900561487 /* AsyncSynchronized.swift */; };
C84893742190FAE900561487 /* Identifiable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C84893722190FAE900561487 /* Identifiable.swift */; };
C8576BE9214EE1F0000A62AE /* RxFeedback.plist in Resources */ = {isa = PBXBuildFile; fileRef = C8576BE5214EE1F0000A62AE /* RxFeedback.plist */; };
C8576BEA214EE1F0000A62AE /* Feedbacks.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8576BE6214EE1F0000A62AE /* Feedbacks.swift */; };
C8576BEB214EE1F1000A62AE /* Deprecations.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8576BE7214EE1F0000A62AE /* Deprecations.swift */; };
Expand Down Expand Up @@ -216,7 215,6 @@
C84645901EB775AF0008AD87 /* SystemError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SystemError.swift; sourceTree = "<group>"; };
C84645921EB78D320008AD87 /* UILabel Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UILabel Extensions.swift"; sourceTree = "<group>"; };
C84893692190FAE900561487 /* AsyncSynchronized.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AsyncSynchronized.swift; sourceTree = "<group>"; };
C84893722190FAE900561487 /* Identifiable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Identifiable.swift; sourceTree = "<group>"; };
C8576BE5214EE1F0000A62AE /* RxFeedback.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = RxFeedback.plist; sourceTree = "<group>"; };
C8576BE6214EE1F0000A62AE /* Feedbacks.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Feedbacks.swift; sourceTree = "<group>"; };
C8576BE7214EE1F0000A62AE /* Deprecations.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Deprecations.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -320,7 318,6 @@
isa = PBXGroup;
children = (
C84893692190FAE900561487 /* AsyncSynchronized.swift */,
C84893722190FAE900561487 /* Identifiable.swift */,
C8576BE5214EE1F0000A62AE /* RxFeedback.plist */,
C8576BE6214EE1F0000A62AE /* Feedbacks.swift */,
C8576BE7214EE1F0000A62AE /* Deprecations.swift */,
Expand Down Expand Up @@ -642,7 639,6 @@
C84893732190FAE900561487 /* AsyncSynchronized.swift in Sources */,
C8576BEB214EE1F1000A62AE /* Deprecations.swift in Sources */,
C8576BEA214EE1F0000A62AE /* Feedbacks.swift in Sources */,
C84893742190FAE900561487 /* Identifiable.swift in Sources */,
C8576BEC214EE1F1000A62AE /* ObservableType RxFeedback.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
2 changes: 1 addition & 1 deletion Examples/Examples/GithubPaginatedSearch.swift
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 144,7 @@ class GithubPaginatedSearchViewController: UIViewController {
// UI, user feedback
bindUI,
// NoUI, automatic feedback
react(query: { $0.loadNextPage }, effects: { resource in
react(request: { $0.loadNextPage }, effects: { resource in
return URLSession.shared.loadRepositories(resource: resource)
.asSignal(onErrorJustReturn: .failure(.offline))
.map(Mutation.response)
Expand Down
10 changes: 6 additions & 4 deletions Examples/Examples/PlayCatch.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 55,13 @@ class PlayCatchViewController: UIViewController {
case .throwToHuman:
return .humanHasIt
}
},
},
scheduler: MainScheduler.instance,
scheduledFeedback:
// UI is human feedback
bindUI,
// NoUI, machine feedback
react(query: { $0.machinePitching }, effects: { () -> Observable<Mutation> in
react(request: { $0.machinePitching }, effects: { (_) -> Observable<Mutation> in
return Observable<Int>
.timer(1.0, scheduler: MainScheduler.instance)
.map { _ in Mutation.throwToHuman }
Expand Down Expand Up @@ -100,7 100,9 @@ extension State {
}
}

var machinePitching: ()? {
return self == .machineHasIt ? () : nil
var machinePitching: PitchRequest? {
return self == .machineHasIt ? PitchRequest() : nil
}
}

struct PitchRequest: Equatable {}
2 changes: 1 addition & 1 deletion Examples/Examples/Todo Feedback.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 18,7 @@ extension Todo {
ui: @escaping Feedback,
synchronizeTask: @escaping (Task) -> Single<SyncState>) -> Driver<Todo> {

let synchronizeFeedback: Feedback = react(query: { $0.tasksToSynchronize }) { task -> Signal<Todo.Mutation> in
let synchronizeFeedback: Feedback = react(requests: { $0.tasksToSynchronize }) { task -> Signal<Todo.Mutation> in
return synchronizeTask(task.value)
.map { Todo.Mutation.synchronizationChanged(task, $0) }
.asSignal(onErrorRecover: { error in Signal.just(.synchronizationChanged(task, .failed(error)))
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 93,7 @@ Observable.system(
// UI is human feedback
bindUI,
// NoUI, machine feedback
react(query: { $0.machinePitching }, effects: { () -> Observable<Mutation> in
react(request: { $0.machinePitching }, effects: { () -> Observable<Mutation> in
return Observable<Int>
.timer(1.0, scheduler: MainScheduler.instance)
.map { _ in Mutation.throwToHuman }
Expand All @@ -114,7 114,7 @@ Driver.system(
// UI, user feedback
bindUI,
// NoUI, automatic feedback
react(query: { $0.loadNextPage }, effects: { resource in
react(request: { $0.loadNextPage }, effects: { resource in
return URLSession.shared.loadRepositories(resource: resource)
.asDriver(onErrorJustReturn: .failure(.offline))
.map(Mutation.response)
Expand Down
8 changes: 0 additions & 8 deletions RxFeedback.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 19,7 @@
C8996C7A1F40C5B6004E5D83 /* Deprecations.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8996C791F40C5B6004E5D83 /* Deprecations.swift */; };
C8996C7C1F40D82A004E5D83 /* String Test.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8996C7B1F40D82A004E5D83 /* String Test.swift */; };
C89B96251EB6964200BDAB24 /* Feedbacks.swift in Sources */ = {isa = PBXBuildFile; fileRef = C89B96241EB6964200BDAB24 /* Feedbacks.swift */; };
C89F167C218F7148009BA457 /* Identifiable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C89F167B218F7148009BA457 /* Identifiable.swift */; };
C8DF7346218F389200945A7C /* AsyncSynchronized.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8DF7345218F389200945A7C /* AsyncSynchronized.swift */; };
E11E0E1E1F766F370031D189 /* ReactNonEquatableLoopsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E11E0E0A1F766C750031D189 /* ReactNonEquatableLoopsTests.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -60,9 58,7 @@
C8996C791F40C5B6004E5D83 /* Deprecations.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Deprecations.swift; sourceTree = "<group>"; };
C8996C7B1F40D82A004E5D83 /* String Test.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "String Test.swift"; sourceTree = "<group>"; };
C89B96241EB6964200BDAB24 /* Feedbacks.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Feedbacks.swift; sourceTree = "<group>"; };
C89F167B218F7148009BA457 /* Identifiable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Identifiable.swift; sourceTree = "<group>"; };
C8DF7345218F389200945A7C /* AsyncSynchronized.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AsyncSynchronized.swift; sourceTree = "<group>"; };
E11E0E0A1F766C750031D189 /* ReactNonEquatableLoopsTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReactNonEquatableLoopsTests.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -125,7 121,6 @@
C89B96241EB6964200BDAB24 /* Feedbacks.swift */,
C8996C791F40C5B6004E5D83 /* Deprecations.swift */,
C8DF7345218F389200945A7C /* AsyncSynchronized.swift */,
C89F167B218F7148009BA457 /* Identifiable.swift */,
);
name = RxFeedback;
path = Sources/RxFeedback;
Expand Down Expand Up @@ -194,7 189,6 @@
C8996C6C1F40A7C1004E5D83 /* RxFeedbackObservableTests.swift */,
C8996C691F40A7A0004E5D83 /* RxFeedbackDriverTests.swift */,
C8996C7B1F40D82A004E5D83 /* String Test.swift */,
E11E0E0A1F766C750031D189 /* ReactNonEquatableLoopsTests.swift */,
C83596431FB22EE900DC7B8F /* ReactEquatableLoopsTests.swift */,
C83596451FB2312D00DC7B8F /* ReactHashableLoopsTests.swift */,
C83596471FB24CAF00DC7B8F /* RxTest.swift */,
Expand Down Expand Up @@ -316,7 310,6 @@
C89B96251EB6964200BDAB24 /* Feedbacks.swift in Sources */,
C8DF7346218F389200945A7C /* AsyncSynchronized.swift in Sources */,
C8996C7A1F40C5B6004E5D83 /* Deprecations.swift in Sources */,
C89F167C218F7148009BA457 /* Identifiable.swift in Sources */,
C834A8691EB6795F00E6B15E /* ObservableType RxFeedback.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -325,7 318,6 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
E11E0E1E1F766F370031D189 /* ReactNonEquatableLoopsTests.swift in Sources */,
C83596441FB22EE900DC7B8F /* ReactEquatableLoopsTests.swift in Sources */,
C83596481FB24CAF00DC7B8F /* RxTest.swift in Sources */,
C8996C6B1F40A7A0004E5D83 /* RxFeedbackDriverTests.swift in Sources */,
Expand Down
Loading

0 comments on commit f0ef2c6

Please sign in to comment.