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

Commit

Permalink
Option to implement sessionDidFinishRequest(_:) (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
joemasilotti authored Oct 7, 2023
1 parent 0a4bff8 commit 98700ea
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
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

0 comments on commit 98700ea

Please sign in to comment.