Closed nth-commit closed 7 years ago
Coundn't you also handle this by adding ignores to your watcher (for example chokidator-socket-emitter)?
@peteruithoven Yeah, you could but is that the best option? The emitter does it's job by notifying of file change events, is it up to the listener to check whether these events are relevant? I guess it's semantics, but is there a use-case where you might attach different listeners to the same emitter to handle different events?
I disagree I think, mainly because watches have costs, you can't watch unlimited files. That's why your probably also ignoring the git ignores and node_modules. So ignoring those html's "right from the gate" also saves you resources.
@nth-commit If you're still wanting this, a PR would be much appreciated.
Best implementation that I can think of would be having the user pass systemjs-hot-reloader
a function that accepts the string module name and returns true or false for inclusion. This is more general then a regex or something like that.
For now I'm closing the issue, feel free to reopen if this is still important to you.
I'm using angular as components, and each component is contained in one directory with component.js (angular module), component-controller.js and component.html. I'm running a watch on all my component.html files, and creating a compiled component.html.js (using gulp-angular-templatecache).
Naturally the hot reloader will handle reloading these scripts and re-bootstrapping the angular page, so I'd like to ignore changes to html files, which, at the moment, cause an unnecessary reload.
A simple matching callback passed into the HotReloader ctor would do the trick. Takes the filename and checks the result for truthiness to decide whether to do the reload.
e.g.
_reloader = new HotReloader('http://localhost:5776', { match: path => path.endsWith('.js') };
Let me know if I'm on the wrong track here. But as far as I could tell there was nothing (in the listener itself, rather than the emitter) that handled this.
Edit: this is my workaround in the meantime: http://pastebin.com/Jr0e1bqz