What is Navigator in wwdc22 in Dive into App Intents.

I try to make app intent but i'm beginner at swift. so I watched wwdc vedio : Dive into App Intents. - https://developer.apple.com/videos/play/wwdc2022/10032 But i don't know what does 'Navigator' means at the code. Navigator used together with shared, than navigator is used ad singleton? Does anyone have whole sample code along with thins video?

struct OpenCurrentlyReading: AppIntent {
    static var title: LocalizedStringResource = "Open Currently Reading"

    @MainActor
    func perform() async throws -> some IntentResult {
        Navigator.shared.openShelf(.currentlyReading)
        return .result()
    }
  
    static var openAppWhenRun: Bool = true
}

Yes, the Navigator class is probably a singleton class here. Probably so that it can be used outside the apps main thread.
It’s basically an ObservableObject object that you can then use as @EnvironmentObject to bind a @Published variable for example to a NavigationStack(path: $navigator.somePath) or TabView(selection: $navigator.someView). This way you can control which view/navigation path the app should navigate to from outside any view. Quite useful for things like Shortcuts.

Code Example

Apple’s NavigationCookbook example uses this technique.

Though, another great example is Booky on GitHub! It’s a great source for the same concept here + generally how AppIntents work for Shortcuts.
Check out the specific places in code her:

What is Navigator in wwdc22 in Dive into App Intents.
 
 
Q