Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce direct produce that allows a type not related to OutputType to be produced. #20

Merged
merged 1 commit into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Sources/StoryFlow/Flow/ImplicitFlow/ImplicitFlow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ extension Flow {
}
return
}

// MARK: Direct

if let to = Flow<Any>.destination(for: (value, Swift.type(of: value))) {
let transition = TransitionInfo(from: from, producedType: Swift.type(of: value), receivedType: type, to: to, isUnwind: false)
if CustomTransition.attempt(transition) == false {
Transition.show(UIViewController.self).go(from, to)
}
return
}

fatalError("Didn't find `UpdateHandling` vc in the navigation stack and `InputRequiring` vc in the project for produced `output` \(value) from `\(Swift.type(of: from))`.")
}
Expand Down
4 changes: 4 additions & 0 deletions Sources/StoryFlow/Interfaces/OuputProducing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ extension OutputProducing where Self: UIViewController {
implicitFlow.proceed(with: output, from: self)
}
}

public func produceDirect<T>(_ output: T) {
Flow<T>.implicit().proceed(with: output, from: self)
}

/**
Explicit transition graph from view controller.
Expand Down
Loading