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 32aafaa2c4
commit 1396de9989
1 changed files with 15 additions and 0 deletions

View File

@ -217,6 +217,12 @@ class Server {
this._hmrFileChangeListener = listener;
}
addFileChangeListener(listener) {
if (this._fileChangeListeners.indexOf(listener) === -1) {
this._fileChangeListeners.push(listener);
}
}
buildBundle(options) {
return Promise.resolve().then(() => {
if (!options.platform) {
@ -288,6 +294,15 @@ class Server {
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
// we rebuild the bundles.
this._debouncedFileChangeHandler(absPath);