Skip to content

Commit

Permalink
Add default handle(update:) implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Domas Nutautas committed Aug 22, 2019
1 parent e603957 commit 9c3a69c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
4 changes: 4 additions & 0 deletions StoryFlow/Interfaces/UpdateHandling.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ public protocol UpdateHandling: _AnyUpdateHandling {
associatedtype UpdateType
func handle(update: UpdateType)
}

extension UpdateHandling where Self: UIViewController {
public func handle(update: UpdateType) {}
}
21 changes: 21 additions & 0 deletions StoryFlowTests/ExplicitFlowTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,27 @@ class ExplicitFlowTests: XCTestCase {

// MARK: Unwind

func testProduce_itUnwindsToUpdateHandlingVc() {

// Arrange
class From: UIViewController, OutputProducing { typealias OutputType = Int }
class To: UIViewController, UpdateHandling { typealias UpdateType = Int }

let to = To().visible()
let from = From()
from.flow = .unwind()

to.show(from, sender: nil)
XCTAssert(currentVc.didAppear())

// Act
from.produce(2018)
XCTAssert(currentVc.didDismiss())

// Assert
XCTAssert(currentVc == to)
}

func testProduce_itUnwindsToUpdateHandlingVcAndPassesOutput() {

// Arrange
Expand Down

0 comments on commit 9c3a69c

Please sign in to comment.