Skip to content

Useful UIViewController extension for composing/creating reusable view controllers – no swizzling or subclassing needed!

License

Notifications You must be signed in to change notification settings

essentialdevelopercom/view-controller-lifecycle-observers

Repository files navigation

UIViewController Lifecycle Observers

Build Status

Useful UIViewController extension for composing/creating reusable view controllers – no swizzling or subclassing needed! Learn more at: https://www.essentialdeveloper.com/articles/composing-view-controllers-part-3-lifecycle-observers-in-swift

controller.onViewWillAppear {
    print("viewWillAppear was called!")
}

This extension is very useful when composing view controllers with other modules. For example:

let analytics = ItemsAnalytics()
itemsListController.onViewDidAppear(run: analytics.reportListPageView)

You can also stop receiving messages by removing observers:

let service = ItemsService()
let observer = controller.onViewWillAppear(run: service.reloadItems)
observer.remove()

About

Useful UIViewController extension for composing/creating reusable view controllers – no swizzling or subclassing needed!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages