Skip to content

Hot Restart should be notified to program code so it can dispose of resources. #42679

Open
@ditman

Description

@ditman

I have a plugin/app that attaches a listener to the window.navigator.connection.onChange Stream.

However, when the app/plugin hot restarts, I don't have any opportunity of canceling my old listener before attaching again.

Since connection.onChange is a DOM global, I end up with callbacks firing multiple times (+1 after each hot reload).

Is there any way I can detect a Hot Restart from app/plugin code before it happens, so I can dispose of the resources I've taken?

See also: flutter/flutter#10437

(I have worked around this issue by writing directly to the onchange property of the underlying DOM object, but that is not "polite")

  • SDK Version: 2.9.0-21.0.dev.flutter-06cb010247 (be) (Tue Jul 7 08:14:51 2020 +0000) on "linux_x64"
  • OS: Linux (doesn't matter)
  • Browser: Chrome (doesn't matter)

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2A bug or feature request we're likely to work onarea-web-jsIssues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.web-dev-compiler

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions