Skip to content

Instantly share code, notes, and snippets.

@asobolevsky
Created June 6, 2020 11:08
Show Gist options
  • Save asobolevsky/c50634646b307ca2ddc779f93472ce13 to your computer and use it in GitHub Desktop.
Save asobolevsky/c50634646b307ca2ddc779f93472ce13 to your computer and use it in GitHub Desktop.
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