mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-16 18:50:07 +08:00
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:
committed by
Facebook Github Bot 5
parent
32aafaa2c4
commit
1396de9989
15
packager/react-packager/src/Server/index.js
vendored
15
packager/react-packager/src/Server/index.js
vendored
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user