Skip to content

Commit

Permalink
added viewWillTransition lifecycle to observer
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurdapaz committed Sep 2, 2023
1 parent ae9a92a commit d90366b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Sources/Voir/LifecycleObserver.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import class UIKit.UIViewController
import class UIKit.UITraitCollection
import UIKit

public protocol LifecycleObserver: AnyObject {
func lifecycleUpdate(_ cycle: Lifecycle)
Expand All @@ -18,5 +17,6 @@ public enum Lifecycle {
case didBecomeActive(_ controller: UIViewController)
case willEnterForeground(_ controller: UIViewController)
case willBecomeInactive(_ controller: UIViewController)
case viewWillTransition(_ controller: UIViewController, _ size: CGSize, _ coordinator: UIViewControllerTransitionCoordinator)
case traitCollectionDidChange(_ controller: UIViewController, _ previousTraitCollection: UITraitCollection?)
}
5 changes: 5 additions & 0 deletions Sources/Voir/VoirController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ open class VoirController<View: VoirComponent, ViewModel: VoirModel>: UIViewCont
stopObservations()
}

open override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransition(to: size, with: coordinator)
notifyObservers(.viewWillTransition(self, size, coordinator))
}

open override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
super.traitCollectionDidChange(previousTraitCollection)
notifyObservers(.traitCollectionDidChange(self, previousTraitCollection))
Expand Down

0 comments on commit d90366b

Please sign in to comment.