mirror of https://github.com/status-im/metro.git
Introduce Packager and App HMR WebSocket connection
Summary: public This diff adds infra to both the Packager and the running app to have a WebSocket based connection between them. This connection is toggled by a new dev menu item, namely `Enable/Disable Hot Loading`. Reviewed By: vjeux Differential Revision: D2787621 fb-gh-sync-id: d1dee769348e4830c28782e7b650d025f2b3a786
This commit is contained in:
parent
ecec0ea842
commit
e6a807a8b7
|
@ -134,6 +134,7 @@ class Server {
|
|||
this._projectRoots = opts.projectRoots;
|
||||
this._bundles = Object.create(null);
|
||||
this._changeWatchers = [];
|
||||
this._fileChangeListeners = [];
|
||||
|
||||
const assetGlobs = opts.assetExts.map(ext => '**/*.' + ext);
|
||||
|
||||
|
@ -175,6 +176,7 @@ class Server {
|
|||
this._fileWatcher.on('all', this._onFileChange.bind(this));
|
||||
|
||||
this._debouncedFileChangeHandler = _.debounce(filePath => {
|
||||
this._fileChangeListeners.forEach(listener => listener(filePath));
|
||||
this._rebuildBundles(filePath);
|
||||
this._informChangeWatchers();
|
||||
}, 50);
|
||||
|
@ -187,6 +189,10 @@ class Server {
|
|||
]);
|
||||
}
|
||||
|
||||
addFileChangeListener(listener) {
|
||||
this._fileChangeListeners.push(listener);
|
||||
}
|
||||
|
||||
buildBundle(options) {
|
||||
return Promise.resolve().then(() => {
|
||||
if (!options.platform) {
|
||||
|
|
Loading…
Reference in New Issue