From 049c4a3cc5739bee3d548b40d5197cc1c9632152 Mon Sep 17 00:00:00 2001 From: Klaidas Strazdauskas Date: Tue, 13 Feb 2024 13:50:42 +0100 Subject: [PATCH] fully allow produce direct from any type. --- 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)