Last change
on this file since 571e0df was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
872 bytes
|
Line | |
---|
1 | /* global __resourceQuery */
|
---|
2 |
|
---|
3 | "use strict";
|
---|
4 |
|
---|
5 | var urlBase = decodeURIComponent(__resourceQuery.slice(1));
|
---|
6 | exports.keepAlive = function (options) {
|
---|
7 | var data = options.data;
|
---|
8 | var onError = options.onError;
|
---|
9 | var active = options.active;
|
---|
10 | var module = options.module;
|
---|
11 | var response;
|
---|
12 | var request = require("http").request(
|
---|
13 | urlBase + data,
|
---|
14 | {
|
---|
15 | agent: false,
|
---|
16 | headers: { accept: "text/event-stream" }
|
---|
17 | },
|
---|
18 | function (res) {
|
---|
19 | response = res;
|
---|
20 | response.on("error", errorHandler);
|
---|
21 | if (!active && !module.hot) {
|
---|
22 | console.log(
|
---|
23 | "Hot Module Replacement is not enabled. Waiting for process restart..."
|
---|
24 | );
|
---|
25 | }
|
---|
26 | }
|
---|
27 | );
|
---|
28 | function errorHandler(err) {
|
---|
29 | err.message =
|
---|
30 | "Problem communicating active modules to the server: " + err.message;
|
---|
31 | onError(err);
|
---|
32 | }
|
---|
33 | request.on("error", errorHandler);
|
---|
34 | request.end();
|
---|
35 | return function () {
|
---|
36 | response.destroy();
|
---|
37 | };
|
---|
38 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.