Skip to content

Commit d6fef25

Browse files
committed
Add configuration to lazy load tabs
1 parent a924da5 commit d6fef25

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

Demo/AppDelegate.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
4242
Hotwire.config.backButtonDisplayMode = .minimal
4343
Hotwire.config.showDoneButtonOnModals = true
4444
Hotwire.config.animateReplaceActions = true
45+
Hotwire.config.lazyLoadTabs = true
4546
#if DEBUG
4647
Hotwire.config.debugLoggingEnabled = true
4748
#endif

Source/HotwireConfig.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ public struct HotwireConfig {
2929
/// Set to `true` to fade content when performing a `replace` visit.
3030
public var animateReplaceActions = false
3131

32+
/// Set to `true` to load each tab after it is selected (instead of on app launch).
33+
public var lazyLoadTabs = false
34+
3235
/// Enable or disable debug logging for Turbo visits and bridge elements
3336
/// connecting, disconnecting, receiving/sending messages, and more.
3437
public var debugLoggingEnabled = false {

Source/Turbo/ViewControllers/HotwireTabBarController.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,12 @@ open class HotwireTabBarController: UITabBarController, NavigationHandler {
3737
public func load(_ tabs: [HotwireTab]) {
3838
hotwireTabs = tabs
3939
setupTabs()
40-
activeNavigator.start()
40+
41+
if Hotwire.config.lazyLoadTabs {
42+
activeNavigator.start()
43+
} else {
44+
navigatorsByIdentifier.values.forEach { $0.start() }
45+
}
4146
}
4247

4348
/// Returns the navigator associated with the given tab.

0 commit comments

Comments
 (0)