Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

poll.js 1.1KB

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. /*globals __resourceQuery */
  6. if (module.hot) {
  7. var hotPollInterval = +__resourceQuery.substr(1) || 10 * 60 * 1000;
  8. var log = require("./log");
  9. var checkForUpdate = function checkForUpdate(fromUpdate) {
  10. if (module.hot.status() === "idle") {
  11. module.hot
  12. .check(true)
  13. .then(function(updatedModules) {
  14. if (!updatedModules) {
  15. if (fromUpdate) log("info", "[HMR] Update applied.");
  16. return;
  17. }
  18. require("./log-apply-result")(updatedModules, updatedModules);
  19. checkForUpdate(true);
  20. })
  21. .catch(function(err) {
  22. var status = module.hot.status();
  23. if (["abort", "fail"].indexOf(status) >= 0) {
  24. log("warning", "[HMR] Cannot apply update.");
  25. log("warning", "[HMR] " + log.formatError(err));
  26. log("warning", "[HMR] You need to restart the application!");
  27. } else {
  28. log("warning", "[HMR] Update failed: " + log.formatError(err));
  29. }
  30. });
  31. }
  32. };
  33. setInterval(checkForUpdate, hotPollInterval);
  34. } else {
  35. throw new Error("[HMR] Hot Module Replacement is disabled.");
  36. }