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

Soft-deprecate ViewRegistry #816

Closed
wants to merge 4 commits into from
Closed

Soft-deprecate ViewRegistry #816

wants to merge 4 commits into from

Conversation

dhavalshreyas
Copy link
Contributor

@dhavalshreyas dhavalshreyas commented Dec 11, 2019

Provides a path for ViewRegistry migration without any breaking API changes.

Individual Screens can move from using register(screenViewControllerType:) to providing a viewControllerDescription.

Initializers for both ScreenViewController and ContainerViewController have default values for ViewRegistry.

This is an awkward intermediate step since we're not gaining any compile-time safety here and are introducing some dangerous side-effects like:

  • a ViewControllerDescription described ViewController cannot build a new ViewController using the ViewRegistry, since it will not have the correct ViewRegistry on init.
  • ViewControllerDescription can only return implementations of ScreenViewController, if not, we'll see a run-time error.

This is the Migration strategy 1 as described in #815

@claassistantio
Copy link

claassistantio commented Dec 11, 2019

CLA assistant check
All committers have signed the CLA.

@dhavalshreyas
Copy link
Contributor Author

Would love some input on this, however I'm out of town until Dec 19th, I will be responding to feedback then.

@dhavalshreyas dhavalshreyas changed the title Soft-deprecate ViewRegistry #815 Soft-deprecate ViewRegistry Dec 11, 2019
@@ -25,6 +25,8 @@ import ReactiveSwift
/// In order for the registry to handle a given screen type, a view factory
/// must first be registered using `register(screenType:factory:)`, where the
/// factory is a simple closure that is responsible for instantiating a view.
///
/// Deprecated: Return the appropriate `ViewControllerDescription` from `Screen` instead
public struct ViewRegistry {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be annotated as deprecated instead of commented as deprecated?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This triggers tons of warnings. Especially on all the Screen initializers. I decided to just use a comment here, and use the annotations for the register call.

@@ -35,7 +35,7 @@ open class ScreenViewController<ScreenType: Screen>: UIViewController {
return ScreenType.self
}

public required init(screen: ScreenType, viewRegistry: ViewRegistry) {
public required init(screen: ScreenType, viewRegistry: ViewRegistry = ViewRegistry()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the default arg?

Signed-off-by: Dhaval Shreyas <dhaval@squareup.com>
@JustinDSN
Copy link
Contributor

Superseded by #974

@JustinDSN JustinDSN closed this Feb 28, 2020
@dhavalshreyas
Copy link
Contributor Author

This change landed here: #974

@dhavalshreyas dhavalshreyas deleted the dhaval/softDepVR branch April 3, 2020 00:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants