Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract DriveDelegate interface #657

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Commits on Sep 14, 2023

  1. Extract DriveDelegate interface

    The `FrameController` depends on the application's singleton `Session`
    instance in several ways:
    
    * it drives the `History`
    * it determines whether or not an `Element` is "enabled" to navigate a
      page or frame
    * it preloads links
    * it dispatches `turbo:frame-render` and `turbo:frame-load` events
    * it can initiate a `Visit`
    
    This commit codifies those dependent behaviors by creating the
    `DriveDelegate` interface and declaring the `Session` class as an
    extension of that interface.
    
    With the codification of the `DriveDelegate` responsibilities
    established, managing `turbo:frame-render` and `turbo:frame-load` events
    feels out of scope. To resolve that, this commit migrates the
    `Session.frameRendered` and `Session.frameLoaded` methods to the
    `FrameController`, and omits them from the `DriveDelegate` interface.
    
    The `FrameController` still directly imports the singleton instance of
    the `Session` from the `src/core/index` module, but assigns it to a
    `delegate: DriveDelegate` property for use throughout the class.
    
    The next step would be to find a way to forward the `session` instance
    into the [FrameElement.delegateConstructor][] assignment.
    
    [FrameElement.delegateConstructor]: https://github.com/hotwired/turbo/blob/3a18111412cb4190b818b96c9c6aad7264cc4441/src/elements/index.ts#L6
    seanpdoyle committed Sep 14, 2023
    Configuration menu
    Copy the full SHA
    317a5cc View commit details
    Browse the repository at this point in the history