Skip to content

Conversation

@seanpdoyle
Copy link
Contributor

@seanpdoyle seanpdoyle commented Feb 24, 2024

Remove all external calls to preloadOnLoadLinksForView. In its place,
introduce a new AttributeObserver to monitor all elements within a
scope that:

  • added the [data-turbo-preload] attribute
  • connected with the [data-turbo-preload] attribute
  • connected with children that have the [data-turbo-preload]
    attribute

The details of this observation are abstracted into the
AttributeObserver, which will notify its delegate whenever those
conditions are met. The delegate is responsible for responding to those
conditions. For example, the Preloader ensures that the element is an
<a> element, and that the element matches the expectations of its
own delegate (the Session instance).

The implementation for the AttributeObserver draws inspiration from
its @hotwired/stimulus counterpart.

Remove all external calls to `preloadOnLoadLinksForView`. In its place,
introduce a new `AttributeObserver` to monitor all elements within a
scope that:

* added the `[data-turbo-preload]` attribute
* connected with the `[data-turbo-preload]` attribute
* connected with children that have the `[data-turbo-preload]`
  attribute

The details of this observation are abstracted into the
`AttributeObserver`, which will notify its delegate whenever those
conditions are met. The delegate is responsible for responding to those
conditions. For example, the `Preloader` ensures that the element is an
`<a>` element, and that the element matches the expectations of **its**
own delegate (the `Session` instance).

The implementation for the `AttributeObserver` draws inspiration from
its [@hotwired/stimulus][] counterpart.

[@hotwired/stimulus]: https://github.com/hotwired/stimulus/blob/v3.2.2/src/mutation-observers/attribute_observer.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants