Skip to content

Commit

Permalink
Merge pull request #91 from iMostfa/feature/add-on-inject-hook
Browse files Browse the repository at this point in the history
Add After injection hook
  • Loading branch information
krzysztofzablocki authored Apr 7, 2024
2 parents d394c53 + 19c7802 commit 1f368dc
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Sources/Inject/Integrations/Hosts.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public typealias ViewHost = _InjectableViewHost
open class _InjectableViewControllerHost<Hosted: InjectViewControllerType>: InjectViewControllerType {
public private(set) var instance: Hosted
let constructor: () -> Hosted
public var afterInjectionHook: (() -> Void)?

public init(_ constructor: @autoclosure @escaping () -> Hosted) {
instance = constructor()
Expand All @@ -32,8 +33,9 @@ open class _InjectableViewControllerHost<Hosted: InjectViewControllerType>: Inje
self.enableInjection()

addAsChild()
onInjection { instance in
onInjection { [weak self] instance in
instance.resetHosted()
self?.afterInjectionHook?()
}
}

Expand Down

0 comments on commit 1f368dc

Please sign in to comment.