Skip to content

Commit 25c4dbc

Browse files
fully allow produce direct from any type. (#25)
1 parent 75cb7d6 commit 25c4dbc

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

Sources/StoryFlow/Flow/ImplicitFlow/ImplicitFlow.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,15 @@ extension Flow {
3636

3737
extension Flow {
3838

39+
private class _VoidOutputTypeProducing: UIViewController, OutputProducing {
40+
typealias OutputType = Void
41+
}
42+
3943
public static func implicit() -> Flow {
4044
return Flow { from, value in
4145

42-
guard let outputProducing = from as? _AnyOutputProducing
43-
else { fatalError("Can't use `Flow.implict()` on vc that is not `OutputProducing` for produced `output` \(value) from `\(Swift.type(of: from))`.") }
44-
46+
let outputProducing = from as? _AnyOutputProducing ?? _VoidOutputTypeProducing()
47+
4548
let output = OutputTransform.unwrapOneOfN((value, Swift.type(of: outputProducing)._outputType))
4649
let (value, type) = OutputTransform.apply(output)
4750

0 commit comments

Comments
 (0)