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

feat: GoodCoordinator init update #12

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@ final class AppCoordinator: GoodCoordinator<AppStep> {

init(window: UIWindow?) {
self.window = window

super.init()
}

required init(rootViewController: UIViewController? = nil, parentCoordinator: (any Coordinator)? = nil) {
required init(rootViewController: UIViewController? = nil) {
fatalError("init(rootViewController:parentCoordinator:) has not been implemented")
}

required convenience init(parentCoordinator: any Coordinator) {
required init(parentCoordinator: Coordinator?) {
fatalError("init(parentCoordinator:) has not been implemented")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class HomeCoordinator: GoodCoordinator<HomeStep> {
switch step {
case .goToAbout:
let aboutViewController = AboutCoordinator(
rootViewController: rootViewController,
parentCoordinator: self
).start()

Expand Down
15 changes: 7 additions & 8 deletions Sources/LegacyReactor/GoodCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,21 +89,20 @@ open class GoodCoordinator<Step>: NSObject, Coordinator {
/// - Parameters:
/// - rootViewController: The root view controller managed by this coordinator. Default value is nil.
/// - parentCoordinator: The parent coordinator of this coordinator. Default value is nil.
public required init(rootViewController: UIViewController? = nil, parentCoordinator: Coordinator? = nil) {
public required init(rootViewController: UIViewController? = nil) {
super.init()

self.rootViewController = rootViewController
self.parentCoordinator = parentCoordinator
self.parentCoordinator?.children.addObject(self)
}

/// A convenience initializer that initializes a GoodCoordinator with a root view controller derived from the provided parent coordinator.
/// - Parameter parentCoordinator: The parent coordinator to which this coordinator will belong.
public required convenience init(parentCoordinator: Coordinator) {
self.init(
rootViewController: parentCoordinator.rootViewController,
parentCoordinator: parentCoordinator
)
public required init(parentCoordinator: Coordinator?) {
super.init()

self.parentCoordinator = parentCoordinator
self.rootViewController = parentCoordinator?.rootViewController
self.parentCoordinator?.children.addObject(self)
}

// MARK: - Overridable
Expand Down