file change listener for relay fragments in packager server

Reviewed By: martinbigio

Differential Revision: D3011797

fb-gh-sync-id: 9f7ddc7b3c0c0e2a78db829343d9fa93a46b4ad6
shipit-source-id: 9f7ddc7b3c0c0e2a78db829343d9fa93a46b4ad6
This commit is contained in:
Steven Chaitoff 2016-03-24 08:07:48 -07:00 committed by Facebook Github Bot 5
parent cccbb342a0
commit 4ea783234b
1 changed files with 15 additions and 0 deletions

View File

@ -217,6 +217,12 @@ class Server {
this._hmrFileChangeListener = listener; this._hmrFileChangeListener = listener;
} }
addFileChangeListener(listener) {
if (this._fileChangeListeners.indexOf(listener) === -1) {
this._fileChangeListeners.push(listener);
}
}
buildBundle(options) { buildBundle(options) {
return Promise.resolve().then(() => { return Promise.resolve().then(() => {
if (!options.platform) { if (!options.platform) {
@ -288,6 +294,15 @@ class Server {
return; return;
} }
Promise.all(
this._fileChangeListeners.map(listener => listener(absPath))
).then(
() => this._onFileChangeComplete(absPath),
() => this._onFileChangeComplete(absPath)
);
}
_onFileChangeComplete(absPath) {
// Make sure the file watcher event runs through the system before // Make sure the file watcher event runs through the system before
// we rebuild the bundles. // we rebuild the bundles.
this._debouncedFileChangeHandler(absPath); this._debouncedFileChangeHandler(absPath);