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:
Martín Bigio
2015-12-28 16:43:08 -08:00
committed by facebook-github-bot-6
parent f72cfdd9fa
commit 90781d3067
5 changed files with 109 additions and 0 deletions

View File

@@ -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) {