realize icon indicating copy to clipboard operation
realize copied to clipboard

Refresh browsers when binary file is rebuilt

Open stephenkoo opened this issue 6 years ago • 7 comments

Proposed feature:

  • Option to automatically refresh the relevant page on Chrome, Firefox and Safari when realize start rebuilds the Go binary file.

stephenkoo avatar Mar 04 '18 23:03 stephenkoo

If this isn't a planned feature, could someone suggest what they use to automatically refresh a browser to reflect the latest changes?

stephenkoo avatar Mar 04 '18 23:03 stephenkoo

i need to check how its work a browser refresh system

asoseil avatar Mar 05 '18 00:03 asoseil

I think air & fresh does this: https://github.com/pilu/fresh https://github.com/cosmtrek/air

Edit: Just tested air, it doesn't seem to do this. Best resource I've found is:

  • https://github.com/markvincze/golang-reload-browser and
  • BrowserSync + golang: https://sequentialread.com/live-reloading-golang-server-with-gulp-and-browser-sync/

stephenkoo avatar Mar 05 '18 00:03 stephenkoo

Great Idea.

s0kil avatar Apr 11 '18 05:04 s0kil

I've been spending ages looking for a tool that does this in golang, I've become accustomed to it from other languages' web frameworks (which recompile and auto refresh the browser on file changes), this would be an awesome addition!

trinode avatar Apr 27 '18 13:04 trinode

The way I imagine this working is we would include some javascript in our app which could be loaded from the realize web server

<script src="http://localhost:5001/autorefresh.js"></script>

(we could do this conditionally depending if we're running in production mode or not, I don't think it would be wise or worth the effort to have Realize proxy the app and inject the script)

  • Realize would need to have a websocket server enabled, this JS would connect to that socket.
  • The user would change the app
  • Realize would rebuild and rerun the app
  • Realize would then send a message via the websocket which would let the JS know it's time to reload
  • The magic happens

I would contribute if you're desperate for someone else to do this, but I'm quite new to go - to the point where I'm looking for the best frameworks and code reload tools :-)

It seems that most of what needed would be in the example https://github.com/markvincze/golang-reload-browser that @stephenkoo posted.

trinode avatar Apr 30 '18 09:04 trinode

i prefer the proxy approach, but i don't know how to get the app url that could be preset or not depending on the type of project

asoseil avatar May 29 '18 12:05 asoseil