Skip to content

Commit

Permalink
fully allow produce direct from any type. (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
klaidas-trafi committed Feb 14, 2024
1 parent 75cb7d6 commit 25c4dbc
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Sources/StoryFlow/Flow/ImplicitFlow/ImplicitFlow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,15 @@ extension Flow {

extension Flow {

private class _VoidOutputTypeProducing: UIViewController, OutputProducing {
typealias OutputType = Void
}

public static func implicit() -> Flow {
return Flow { from, value in

guard let outputProducing = from as? _AnyOutputProducing
else { fatalError("Can't use `Flow.implict()` on vc that is not `OutputProducing` for produced `output` \(value) from `\(Swift.type(of: from))`.") }

let outputProducing = from as? _AnyOutputProducing ?? _VoidOutputTypeProducing()

let output = OutputTransform.unwrapOneOfN((value, Swift.type(of: outputProducing)._outputType))
let (value, type) = OutputTransform.apply(output)

Expand Down

0 comments on commit 25c4dbc

Please sign in to comment.