123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- "use strict";
- const asyncLib = require("neo-async");
- class MultiWatching {
-
- constructor(watchings, compiler) {
- this.watchings = watchings;
- this.compiler = compiler;
- }
-
- invalidate(callback) {
- if (callback) {
- asyncLib.each(
- this.watchings,
- (watching, callback) => watching.invalidate(callback),
- callback
- );
- } else {
- for (const watching of this.watchings) {
- watching.invalidate();
- }
- }
- }
- suspend() {
- for (const watching of this.watchings) {
- watching.suspend();
- }
- }
- resume() {
- for (const watching of this.watchings) {
- watching.resume();
- }
- }
-
- close(callback) {
- asyncLib.forEach(
- this.watchings,
- (watching, finishedCallback) => {
- watching.close(finishedCallback);
- },
- err => {
- this.compiler.hooks.watchClose.call();
- if (typeof callback === "function") {
- this.compiler.running = false;
- callback(err);
- }
- }
- );
- }
- }
- module.exports = MultiWatching;
|