Skip to content
This repository has been archived by the owner on Oct 10, 2024. It is now read-only.

Option to implement sessionDidFinishRequest(_:) #59

Merged
merged 1 commit into from
Oct 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Sources/TurboNavigationDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ public protocol TurboNavigationDelegate: AnyObject {
/// Optional. Implement to become the web view's navigation delegate after the initial cold boot visit is completed.
/// https://github.com/hotwired/turbo-ios/blob/main/Docs/Overview.md#becoming-the-web-views-navigation-delegate
func sessionDidLoadWebView(_ session: Session)

/// Optional. Useful for interacting with the web view after the page loads.
func sessionDidFinishRequest(_ session: Session)
}

public extension TurboNavigationDelegate {
Expand All @@ -57,5 +60,7 @@ public extension TurboNavigationDelegate {
completionHandler(.performDefaultHandling, nil)
}

func sessionDidFinishRequest(_ session: Session) {}

func sessionDidLoadWebView(_ session: Session) {}
}
4 changes: 4 additions & 0 deletions Sources/TurboNavigator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,10 @@ extension TurboNavigator: SessionDelegate {
delegate.didReceiveAuthenticationChallenge(challenge, completionHandler: completionHandler)
}

public func sessionDidFinishRequest(_ session: Session) {
delegate.sessionDidFinishRequest(session)
}

public func sessionDidLoadWebView(_ session: Session) {
session.webView.navigationDelegate = session
delegate.sessionDidLoadWebView(session)
Expand Down