The current design requires the developer to explicitly press 'hot reload' to see the effect of changes. It has been suggested that this should happen implicitly & automatically. This should probably be tied to the state of the analyzer so that we only push changes that are valid.
Not fully convinced this is going to work (it may cause more issues then expected), but enough users have suggested it that we aught to make an experiment.
Developers should be in control of when a hot reload happens and we shouldn't do it automatically.
I personally share that sentiment, but we have had enough customers ask for it now that we should not just reject it.
Worth an investigation here. Maybe the issue is "it's too hard to trigger hot reload", which is slightly different than "do it automatically".
I use the "live" hot reload mode for a React project, and it's really nice for making tiny UI tweaks. I agree that it should be toggle-able, as many times you'll make a breaking change after saving one file and need to finish the change in other files. That, or your project is large enough that the hot reload takes more than a second.
In IntelliJ, we might consider tying this to the save action, so this would become reload-on-save. You generally don't need to save files in IntelliJ; their cmd-S save action is mapped to a save all dirty files command. We have seen however that people still do hit cmd-s while working, and from user studies, there is some expectation that saving a file will reload it on the device.
I really like the idea of tying this to save. I think that will work particularly well for devs with a web background where reload tools are often based on file watchers, and saving to reload is thus trained behavior.
Cool! There's a PR here: https://github.com/flutter/flutter-intellij/pull/910. We wouldn't land that, but it's a proof of concept. Tao found one issue where changing focus away from IntelliJ triggers an auto-save, which then triggers a reload, which is unexpected. So we'd want to adjust when a save triggers a reload, as well as likely additional validation against the analysis server results.
Yes, would be good if we could tie it to explicit saves, not auto-saves.
Just FYI.
Help page about updating running JavaEE app in IntelliJ IDEA: link
Among not numerous 'do smth on save' action WebStorm/PhpStorm have 'Upload changed files automatically to the default server' option in Preferences | Build, Execution, Deployment | Deployment | Options. One of the possible option values is 'On explicit save action'. Unfortunately, its implementation is not in the open-source repo. And the implementation is quite complex, but looks like they use com.intellij.openapi.actionSystem.ex.AnActionListener to distinguish explicit saves.
re: com.intellij.openapi.actionSystem.ex.AnActionListener - thanks! I would have needed to do a bunch of code sleuthing to find that :)
Idea for UI when un/successfully doing a hot reload on save. Create an inline "hint" like we do for calls to dartfmt:
use vs-code to lunch ,can debug by step by step and reload on save.
Here is a solution for Emacs:
(defun flutter-reload ()
(interactive) (shell-command "kill -SIGUSR1 $(cat /tmp/flutter.pid)"))
(add-hook 'after-save-hook 'flutter-reload)
Most helpful comment
I use the "live" hot reload mode for a React project, and it's really nice for making tiny UI tweaks. I agree that it should be toggle-able, as many times you'll make a breaking change after saving one file and need to finish the change in other files. That, or your project is large enough that the hot reload takes more than a second.