Skip to content

Commit a76e4a2

Browse files
committed
fix(server): remove setInterval hack
1 parent 5b7bfa3 commit a76e4a2

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

packages/core/src/lib/server.js

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -90,22 +90,16 @@ const server = patternlab => {
9090
return new Promise((resolve, reject) => {
9191
let action;
9292
try {
93-
const reloadInterval = setInterval(() => {
94-
if (!patternlab.isBusy) {
95-
if (
96-
_data.file.indexOf('css') > -1 ||
97-
_data.action === 'refresh'
98-
) {
99-
action = 'refreshed CSS';
100-
liveServer.refreshCSS();
101-
} else {
102-
action = 'reloaded';
103-
liveServer.reload();
104-
}
105-
clearInterval(reloadInterval);
106-
resolve(`Server ${action} successfully`);
93+
if (!patternlab.isBusy) {
94+
if (_data.file.indexOf('css') > -1 || _data.action === 'refresh') {
95+
action = 'refreshed CSS';
96+
liveServer.refreshCSS();
97+
} else {
98+
action = 'reloaded';
99+
liveServer.reload();
107100
}
108-
}, 1000);
101+
resolve(`Server ${action} successfully`);
102+
}
109103
} catch (e) {
110104
reject(`Server reload or refresh failed: ${e}`);
111105
}

0 commit comments

Comments
 (0)