Skip to content

Commit

Permalink
[master] - 'Dunno why I ever called it callback...changed name to mak…
Browse files Browse the repository at this point in the history
…e more sense - TT'
  • Loading branch information
Tyler-Keith-Thompson committed Oct 20, 2019
1 parent fc569d8 commit 45f7e51
Show file tree
Hide file tree
Showing 43 changed files with 108 additions and 81 deletions.
4 changes: 2 additions & 2 deletions Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ PODS:
- CwlCatchException (1.0.2)
- CwlPreconditionTesting (1.1.1):
- CwlCatchException
- DynamicWorkflow (0.0.7)
- DynamicWorkflow (0.0.10)
- UIUTest (1.6.0)

DEPENDENCIES:
Expand Down Expand Up @@ -36,7 +36,7 @@ CHECKOUT OPTIONS:
SPEC CHECKSUMS:
CwlCatchException: 70a52ae44ea5d46db7bd385f801a94942420cd8c
CwlPreconditionTesting: d33a4e4f285c0b885fddcae5dfedfbb34d4f3961
DynamicWorkflow: 214b6218b7e17dc458c865ea5f09436bf4922da5
DynamicWorkflow: a977fca94a5318fb6c6fa95f4d041e8656a80446
UIUTest: 842c642e5bec098b1e2c890cbe25aacab80f2481

PODFILE CHECKSUM: 5f55f064de83e2e4f31f04427448900a8e9571f2
Expand Down
36 changes: 21 additions & 15 deletions Workflow.xcodeproj/xcshareddata/xcschemes/Workflow.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,17 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
codeCoverageEnabled = "YES"
shouldUseLaunchSchemeArgsEnv = "YES">
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "ADD8235D2312CC6300D77D3C"
BuildableName = "Workflow.framework"
BlueprintName = "Workflow"
ReferencedContainer = "container:Workflow.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
<TestableReference
skipped = "NO">
Expand All @@ -39,18 +48,17 @@
ReferencedContainer = "container:Workflow.xcodeproj">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "ADEE774E233BAA6C007E9FD2"
BuildableName = "WorkflowExampleTests.xctest"
BlueprintName = "WorkflowExampleTests"
ReferencedContainer = "container:Workflow.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "ADD8235D2312CC6300D77D3C"
BuildableName = "Workflow.framework"
BlueprintName = "Workflow"
ReferencedContainer = "container:Workflow.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
Expand All @@ -71,8 +79,6 @@
ReferencedContainer = "container:Workflow.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
2 changes: 1 addition & 1 deletion Workflow/Protocols/FlowRepresentable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,6 @@ public extension FlowRepresentable {
}

func proceedInWorkflow(_ args:Any? = nil) {
callback?(args)
proceedInWorkflow?(args)
}
}
2 changes: 1 addition & 1 deletion Workflow/Protocols/TypeErased/AnyFlowRepresentable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public protocol AnyFlowRepresentable {
/// workflow: Access to the `Workflow` controlling the `FlowRepresentable`. A common use case may be a `FlowRepresentable` that wants to abandon the `Workflow` it's in.
/// - Note: While not strictly necessary it would be wise to declare this property as `weak`
var workflow:Workflow? { get set }
var callback:((Any?) -> Void)? { get set }
var proceedInWorkflow:((Any?) -> Void)? { get set }

mutating func erasedShouldLoad(with args:Any?) -> Bool

Expand Down
2 changes: 1 addition & 1 deletion Workflow/UIKitPresenter/UIWorkflowItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import UIKit
*/

open class UIWorkflowItem<I>: UIViewController {
public var callback: ((Any?) -> Void)?
public var proceedInWorkflow: ((Any?) -> Void)?

public typealias IntakeType = I

Expand Down
12 changes: 6 additions & 6 deletions Workflow/Workflow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public class Workflow: LinkedList<AnyFlowRepresentable.Type> {
}

private func removeInstances() {
instances.forEach { $0.value?.callback = nil }
instances.forEach { $0.value?.proceedInWorkflow = nil }
instances.removeAll()
self.firstLoadedInstance = nil
}
Expand All @@ -111,21 +111,21 @@ public class Workflow: LinkedList<AnyFlowRepresentable.Type> {
}

private func setupCallbacks(for node:LinkedList<AnyFlowRepresentable?>.Node<AnyFlowRepresentable?>, onFinish:((Any?) -> Void)?) {
node.value?.callback = { args in
node.value?.proceedInWorkflow = { args in
var argsToPass = args
let nextNode = node.next?.traverse {
let index = $0.position
var instance = self.first?.traverse(index)?.value.instance()
instance?.callback = $0.value?.callback
instance?.proceedInWorkflow = $0.value?.proceedInWorkflow
instance?.workflow = self

let hold = instance?.callback
let hold = instance?.proceedInWorkflow
defer {
instance?.callback = hold
instance?.proceedInWorkflow = hold
self.replaceInstance(atIndex: index, withInstance: instance)
}

instance?.callback = { argsToPass = $0 }
instance?.proceedInWorkflow = { argsToPass = $0 }

return instance?.erasedShouldLoad(with: argsToPass) == true
}
Expand Down
2 changes: 1 addition & 1 deletion WorkflowExampleTests/EnterAddressViewControllerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class EnterAddressViewControllerTests: ViewControllerTest<EnterAddressViewContro
let order = Order(location: nil)
testViewController.order = order

testViewController.callback = { data in
testViewController.proceedInWorkflow = { data in
proceedInWorkflowCalled = true
XCTAssertEqual((data as? Order)?.orderType, .delivery(Address()))
}
Expand Down
6 changes: 3 additions & 3 deletions WorkflowExampleTests/FoodSelectionViewControllerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class FoodSelectionViewControllerTests: ViewControllerTest<FoodSelectionViewCont
let order = Order(location: Location(name: "", address: Address(), orderTypes: [], menuTypes: []))
testViewController.order = order
var proceedInWorkflowCalled = false
testViewController.callback = { data in
testViewController.proceedInWorkflow = { data in
proceedInWorkflowCalled = true
XCTAssertEqual((data as? Order)?.shoppingCart.last?.name, "Combo #1")
}
Expand All @@ -33,7 +33,7 @@ class FoodSelectionViewControllerTests: ViewControllerTest<FoodSelectionViewCont
let order = Order(location: Location(name: "", address: Address(), orderTypes: [], menuTypes: []))
testViewController.order = order
var proceedInWorkflowCalled = false
testViewController.callback = { data in
testViewController.proceedInWorkflow = { data in
proceedInWorkflowCalled = true
XCTAssertEqual((data as? Order)?.shoppingCart.last?.name, "Combo #2")
}
Expand All @@ -46,7 +46,7 @@ class FoodSelectionViewControllerTests: ViewControllerTest<FoodSelectionViewCont
let order = Order(location: Location(name: "", address: Address(), orderTypes: [], menuTypes: []))
testViewController.order = order
var proceedInWorkflowCalled = false
testViewController.callback = { data in
testViewController.proceedInWorkflow = { data in
proceedInWorkflowCalled = true
XCTAssertEqual((data as? Order)?.shoppingCart.last?.name, "Combo #3")
}
Expand Down
4 changes: 2 additions & 2 deletions WorkflowExampleTests/LocationsViewControllerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class LocationsViewControllerTests:ViewControllerTest<LocationsViewController> {
let rand = UUID().uuidString
var callbackCalled = false
loadFromStoryboard { viewController in
viewController.callback = { data in
viewController.proceedInWorkflow = { data in
callbackCalled = true
XCTAssert(data is Order, "View should pass on data as an order object")
XCTAssertEqual((data as? Order)?.location?.name, rand, "The location in the order should be the same one selected")
Expand Down Expand Up @@ -88,7 +88,7 @@ class LocationsViewControllerTests:ViewControllerTest<LocationsViewController> {
Location(name: rand, address: Address(line1: "", line2: "", city: "", state: "", zip: ""), orderTypes: [], menuTypes: []),
Location(name: "", address: Address(line1: "", line2: "", city: "", state: "", zip: ""), orderTypes: [], menuTypes: [])
])
viewController.callback = { data in
viewController.proceedInWorkflow = { data in
callbackCalled = true
XCTAssert(data is Order, "View should pass on data as an order object")
XCTAssertEqual((data as? Order)?.location?.name, rand, "The location in the order should be the same one selected")
Expand Down
6 changes: 3 additions & 3 deletions WorkflowExampleTests/MenuSelectionViewControllerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class MenuSelectionViewControllerTests: ViewControllerTest<MenuSelectionViewCont
var proceedInWorkflowCalled = false
let locationWithOne = Location(name: "", address: Address(), orderTypes: [], menuTypes: [.catering])

testViewController.callback = { data in
testViewController.proceedInWorkflow = { data in
proceedInWorkflowCalled = true
XCTAssertEqual((data as? Order)?.menuType, .catering)
}
Expand All @@ -38,7 +38,7 @@ class MenuSelectionViewControllerTests: ViewControllerTest<MenuSelectionViewCont
let locationWithMultiple = Location(name: "", address: Address(), orderTypes: [], menuTypes: [.regular, .catering])
testViewController.order = Order(location: locationWithMultiple)

testViewController.callback = { data in
testViewController.proceedInWorkflow = { data in
proceedInWorkflowCalled = true
XCTAssertEqual((data as? Order)?.menuType, .catering)
}
Expand All @@ -53,7 +53,7 @@ class MenuSelectionViewControllerTests: ViewControllerTest<MenuSelectionViewCont
let locationWithMultiple = Location(name: "", address: Address(), orderTypes: [], menuTypes: [.regular, .catering])
testViewController.order = Order(location: locationWithMultiple)

testViewController.callback = { data in
testViewController.proceedInWorkflow = { data in
proceedInWorkflowCalled = true
XCTAssertEqual((data as? Order)?.menuType, .regular)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class PickupOrDeliveryViewConrollerTests:ViewControllerTest<PickupOrDeliveryView
var callbackCalled = false
let locationWithOne = Location(name: "", address: Address(), orderTypes: [.delivery(Address())], menuTypes: [])
loadFromStoryboard { viewController in
viewController.callback = { data in
viewController.proceedInWorkflow = { data in
callbackCalled = true
XCTAssert(data is Order)
XCTAssertEqual((data as? Order)?.orderType, .delivery(Address()))
Expand All @@ -39,7 +39,7 @@ class PickupOrDeliveryViewConrollerTests:ViewControllerTest<PickupOrDeliveryView
var callbackCalled = false
let location = Location(name: "", address: Address(), orderTypes: [.pickup, .delivery(Address())], menuTypes: [])
loadFromStoryboard { viewController in
viewController.callback = { data in
viewController.proceedInWorkflow = { data in
callbackCalled = true
XCTAssert(data is Order)
XCTAssertEqual((data as? Order)?.orderType, .pickup)
Expand Down Expand Up @@ -68,7 +68,7 @@ class PickupOrDeliveryViewConrollerTests:ViewControllerTest<PickupOrDeliveryView
listener.workflow?.applyPresenter(mock)

var proceedInWorkflowCalled = false
testViewController.callback = { data in
testViewController.proceedInWorkflow = { data in
proceedInWorkflowCalled = true
XCTAssertEqual(data as? Int, 2)
}
Expand Down
14 changes: 7 additions & 7 deletions WorkflowTests/UIKitPresenterTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class UIKitPresenterTests: XCTestCase {

var workflow: Workflow?

var callback: ((Any?) -> Void)?
var proceedInWorkflow: ((Any?) -> Void)?

typealias IntakeType = Void?

Expand Down Expand Up @@ -52,7 +52,7 @@ class UIKitPresenterTests: XCTestCase {

var workflow: Workflow?

var callback: ((Any?) -> Void)?
var proceedInWorkflow: ((Any?) -> Void)?

typealias IntakeType = String?

Expand All @@ -73,7 +73,7 @@ class UIKitPresenterTests: XCTestCase {

var workflow: Workflow?

var callback: ((Any?) -> Void)?
var proceedInWorkflow: ((Any?) -> Void)?

typealias IntakeType = Int?

Expand Down Expand Up @@ -105,7 +105,7 @@ class UIKitPresenterTests: XCTestCase {

var workflow: Workflow?

var callback: ((Any?) -> Void)?
var proceedInWorkflow: ((Any?) -> Void)?

typealias IntakeType = Void?

Expand Down Expand Up @@ -141,7 +141,7 @@ class UIKitPresenterTests: XCTestCase {

var workflow: Workflow?

var callback: ((Any?) -> Void)?
var proceedInWorkflow: ((Any?) -> Void)?

typealias IntakeType = Void?

Expand Down Expand Up @@ -183,7 +183,7 @@ class UIKitPresenterTests: XCTestCase {

var workflow: Workflow?

var callback: ((Any?) -> Void)?
var proceedInWorkflow: ((Any?) -> Void)?

typealias IntakeType = Void?

Expand Down Expand Up @@ -226,7 +226,7 @@ class UIKitPresenterTests: XCTestCase {

var workflow: Workflow?

var callback: ((Any?) -> Void)?
var proceedInWorkflow: ((Any?) -> Void)?

typealias IntakeType = Void?

Expand Down
8 changes: 4 additions & 4 deletions WorkflowTests/WorkflowTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class WorkflowTests: XCTestCase {

var workflow: Workflow?

var callback: ((Any?) -> Void)?
var proceedInWorkflow: ((Any?) -> Void)?

static var shouldLoadCalledOnFR1 = false
typealias IntakeType = String
Expand All @@ -44,7 +44,7 @@ class WorkflowTests: XCTestCase {

var workflow: Workflow?

var callback: ((Any?) -> Void)?
var proceedInWorkflow: ((Any?) -> Void)?

static var shouldLoadCalledOnFR2 = false
typealias IntakeType = Int
Expand Down Expand Up @@ -80,7 +80,7 @@ class WorkflowTests: XCTestCase {

var workflow: Workflow?

var callback: ((Any?) -> Void)?
var proceedInWorkflow: ((Any?) -> Void)?

static var shouldLoadCalledOnFR1 = false
typealias IntakeType = Any?
Expand Down Expand Up @@ -222,7 +222,7 @@ class WorkflowTests: XCTestCase {
class TestFlowRepresentable<I> {
var preferredLaunchStyle: PresentationType = .default

var callback: ((Any?) -> Void)?
var proceedInWorkflow: ((Any?) -> Void)?

typealias IntakeType = I

Expand Down
2 changes: 1 addition & 1 deletion docs/Classes.html
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ <h4>Declaration</h4>
</section>
</section>
<section id="footer">
<p>&copy; 2019 <a class="link" href="https://github.com/Tyler-Keith-Thompson/Workflow" target="_blank" rel="external">Tyler.Thompson</a>. All rights reserved. (Last updated: 2019-10-19)</p>
<p>&copy; 2019 <a class="link" href="https://github.com/Tyler-Keith-Thompson/Workflow" target="_blank" rel="external">Tyler.Thompson</a>. All rights reserved. (Last updated: 2019-10-20)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.11.2</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
Expand Down
2 changes: 1 addition & 1 deletion docs/Classes/LinkedList.html
Original file line number Diff line number Diff line change
Expand Up @@ -1859,7 +1859,7 @@ <h4>Return Value</h4>
</section>
</section>
<section id="footer">
<p>&copy; 2019 <a class="link" href="https://github.com/Tyler-Keith-Thompson/Workflow" target="_blank" rel="external">Tyler.Thompson</a>. All rights reserved. (Last updated: 2019-10-19)</p>
<p>&copy; 2019 <a class="link" href="https://github.com/Tyler-Keith-Thompson/Workflow" target="_blank" rel="external">Tyler.Thompson</a>. All rights reserved. (Last updated: 2019-10-20)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.11.2</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
Expand Down
2 changes: 1 addition & 1 deletion docs/Classes/LinkedList/Node.html
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ <h4>Declaration</h4>
</section>
</section>
<section id="footer">
<p>&copy; 2019 <a class="link" href="https://github.com/Tyler-Keith-Thompson/Workflow" target="_blank" rel="external">Tyler.Thompson</a>. All rights reserved. (Last updated: 2019-10-19)</p>
<p>&copy; 2019 <a class="link" href="https://github.com/Tyler-Keith-Thompson/Workflow" target="_blank" rel="external">Tyler.Thompson</a>. All rights reserved. (Last updated: 2019-10-20)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.11.2</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
Expand Down
2 changes: 1 addition & 1 deletion docs/Classes/Workflow.html
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ <h4>Return Value</h4>
</section>
</section>
<section id="footer">
<p>&copy; 2019 <a class="link" href="https://github.com/Tyler-Keith-Thompson/Workflow" target="_blank" rel="external">Tyler.Thompson</a>. All rights reserved. (Last updated: 2019-10-19)</p>
<p>&copy; 2019 <a class="link" href="https://github.com/Tyler-Keith-Thompson/Workflow" target="_blank" rel="external">Tyler.Thompson</a>. All rights reserved. (Last updated: 2019-10-20)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.11.2</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
Expand Down
2 changes: 1 addition & 1 deletion docs/Enums.html
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ <h4>Declaration</h4>
</section>
</section>
<section id="footer">
<p>&copy; 2019 <a class="link" href="https://github.com/Tyler-Keith-Thompson/Workflow" target="_blank" rel="external">Tyler.Thompson</a>. All rights reserved. (Last updated: 2019-10-19)</p>
<p>&copy; 2019 <a class="link" href="https://github.com/Tyler-Keith-Thompson/Workflow" target="_blank" rel="external">Tyler.Thompson</a>. All rights reserved. (Last updated: 2019-10-20)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.11.2</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
Expand Down
2 changes: 1 addition & 1 deletion docs/Enums/PresentationType.html
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ <h4>Declaration</h4>
</section>
</section>
<section id="footer">
<p>&copy; 2019 <a class="link" href="https://github.com/Tyler-Keith-Thompson/Workflow" target="_blank" rel="external">Tyler.Thompson</a>. All rights reserved. (Last updated: 2019-10-19)</p>
<p>&copy; 2019 <a class="link" href="https://github.com/Tyler-Keith-Thompson/Workflow" target="_blank" rel="external">Tyler.Thompson</a>. All rights reserved. (Last updated: 2019-10-20)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.11.2</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
Expand Down
Loading

0 comments on commit 45f7e51

Please sign in to comment.