From f5de6597719b84de7c00fdcffa155edbb5da3781 Mon Sep 17 00:00:00 2001 From: klaidas-trafi <115455720+klaidas-trafi@users.noreply.github.com> Date: Mon, 6 Nov 2023 15:22:29 +0200 Subject: [PATCH] make produceDirect work in unwind scenarios (#21) --- .../StoryFlow/Flow/ImplicitFlow/ImplicitFlow.swift | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Sources/StoryFlow/Flow/ImplicitFlow/ImplicitFlow.swift b/Sources/StoryFlow/Flow/ImplicitFlow/ImplicitFlow.swift index 373314a..5bea20c 100644 --- a/Sources/StoryFlow/Flow/ImplicitFlow/ImplicitFlow.swift +++ b/Sources/StoryFlow/Flow/ImplicitFlow/ImplicitFlow.swift @@ -66,7 +66,18 @@ extension Flow { return } - // MARK: Direct + // MARK: Direct Unwind + + if let to = from.unwindVc(for: Swift.type(of: value)) { + to.handleUpdate(value, type) + let transition = TransitionInfo(from: from, producedType: output.type, receivedType: type, to: to, isUnwind: true) + if CustomTransition.attempt(transition) == false { + Transition.unwind().go(from, to) + } + return + } + + // MARK: Direct Input if let to = Flow.destination(for: (value, Swift.type(of: value))) { let transition = TransitionInfo(from: from, producedType: Swift.type(of: value), receivedType: type, to: to, isUnwind: false)