From 25c4dbc373c3a01d6012bfcf605e276af586a47c Mon Sep 17 00:00:00 2001 From: klaidas-trafi <115455720+klaidas-trafi@users.noreply.github.com> Date: Wed, 14 Feb 2024 11:15:09 +0100 Subject: [PATCH] fully allow produce direct from any type. (#25) --- Sources/StoryFlow/Flow/ImplicitFlow/ImplicitFlow.swift | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Sources/StoryFlow/Flow/ImplicitFlow/ImplicitFlow.swift b/Sources/StoryFlow/Flow/ImplicitFlow/ImplicitFlow.swift index a780300..39e66ef 100644 --- a/Sources/StoryFlow/Flow/ImplicitFlow/ImplicitFlow.swift +++ b/Sources/StoryFlow/Flow/ImplicitFlow/ImplicitFlow.swift @@ -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)