Skip to content

Filesystem watchers for .dart files. #2074

Closed

Description

@gskinner

I'm working on a tool that modifies .dart files in a Flutter project. It is a helper tool - VS Code would still be the primary IDE.

Right now, changes to files made by the tool are reflected in VSC, but the change does not trigger a hot-reload. This means that after making edits in the other tool, I have to hit save on a file in VSC in order to trigger the hot-reload.

Ideally, I could open a Flutter project in VS Code, start a debug session, swap over to another tool and make updates to files there, and hot-reload would trigger without having to swap back to VSC.

Activity

  1. added this to the v3.7.0 milestone on Oct 30, 2019
  2. added
    in flutterRelates to running Flutter apps
    is enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.
    on Oct 30, 2019
  3. DanTup commented on Oct 30, 2019

    @DanTup
    Member

    It wouldn't be difficult to change this - however I'm a little worried about it re-introducing issues like #1427. VS Code has an option for auto-saving and when we use to hot-reload on every one of them, it was really frustrating. So we added a long delay so if the user didn't explicitly press save, we could add a huge debounce delay.

    Doing that here would mean you'd have to wait some long period before the hot reload was triggered.

    I wonder if there's a better way you could do this from the tool (for ex. if you get the pid of the process - for example by using the --pid-file switch) you could send a SIGUSR1 signal:

        --pid-file          Specify a file to write the process id to. You can send SIGUSR1 to trigger a hot reload and SIGUSR2 to
                            trigger a hot restart.
    
  4. added and removed
    is enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.
    on Oct 30, 2019
  5. added a commit that references this issue on Nov 14, 2019
    a1b9cbf
  6. DanTup commented on Nov 14, 2019

    @DanTup
    Member

    I've added a new setting dart.previewHotReloadOnSaveWatcher which will switch to using a fs watcher for hot reload. It still applies a 200ms debounce to try to avoid firing too much (this means if you're writing lots of files, it'll only fire after there has been a gap of 200ms between any events).

    There's a build here if you'd like to try it out:

    https://github.com/Dart-Code/Dart-Code/releases/tag/v3.7.0-alpha.1

  7. gskinner commented on Nov 14, 2019

    @gskinner
    Author

    Awesome. Thanks @DanTup - I'll give that a try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions