Skip to content

Commit 25e2f42

Browse files
alan-agius4dherges
authored andcommitted
fix: debounce when a file changes (#975)
In some cases on windows the same event is emitted twice. Instead of throttle we should debounce. Also, the same think happen when a folder is renamed, so we only trigger the build once.
1 parent 6bbedee commit 25e2f42

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/lib/file/file-watcher.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export function createFileWatch(
2323
});
2424

2525
const handleFileChange = (event: FileWatchEvent, filePath: string, observer: Observer<FileChangedEvent>) => {
26-
log.debug(`Watch: file changed ${filePath}`);
26+
log.debug(`Watch: Path changed. Event: ${event}, Path: ${filePath}`);
2727

2828
observer.next({
2929
filePath: path.resolve(ensureUnixPath(filePath)),

src/lib/ng-v5/package.transform.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Observable, concat as concatStatic, from as fromPromise, of as observableOf, pipe, EMPTY } from 'rxjs';
2-
import { concatMap, map, switchMap, takeLast, tap, mapTo, catchError, startWith, throttleTime } from 'rxjs/operators';
2+
import { concatMap, map, switchMap, takeLast, tap, mapTo, catchError, startWith, debounceTime } from 'rxjs/operators';
33
import { BuildGraph } from '../brocc/build-graph';
44
import { DepthBuilder } from '../brocc/depth';
55
import { STATE_IN_PROGESS } from '../brocc/node';
@@ -115,10 +115,10 @@ const watchTransformFactory = (
115115
}
116116
})
117117
),
118+
debounceTime(200),
118119
tap(() => log.msg(FileChangeDetected)),
119120
startWith(undefined),
120-
mapTo(graph),
121-
throttleTime(200)
121+
mapTo(graph)
122122
);
123123
}),
124124
switchMap(graph => {

0 commit comments

Comments
 (0)