Created
June 6, 2020 11:08
-
-
Save asobolevsky/c50634646b307ca2ddc779f93472ce13 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum BehaviorStage { | |
case afterLoading(_ closure: BehaviorClosure) | |
case beforeAppearing(_ closure: BehaviorClosure) | |
case afterAppearing(_ closure: BehaviorClosure) | |
case beforeDisappearing(_ closure: BehaviorClosure) | |
case afterDisappearing(_ closure: BehaviorClosure) | |
case beforeLayingOutSubviews(_ closure: BehaviorClosure) | |
case afterLayingOutSubviews(_ closure: BehaviorClosure) | |
} | |
func anonimousBehavior(with stage: BehaviorStage) -> ViewControllerLifecycleBehavior { | |
switch stage { | |
case .afterLoading(let closure): return createAnonimousBehavior(afterLoading: closure) | |
case .beforeAppearing(let closure): return createAnonimousBehavior(beforeAppearing: closure) | |
case .afterAppearing(let closure): return createAnonimousBehavior(afterAppearing: closure) | |
case .beforeDisappearing(let closure): return createAnonimousBehavior(beforeDisappearing: closure) | |
case .afterDisappearing(let closure): return createAnonimousBehavior(afterDisappearing: closure) | |
case .beforeLayingOutSubviews(let closure): return createAnonimousBehavior(beforeLayingOutSubviews: closure) | |
case .afterLayingOutSubviews(let closure): return createAnonimousBehavior(afterLayingOutSubviews: closure) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment