SystemTickFeed.jsm 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. "use strict";
  5. const {actionTypes: at} = ChromeUtils.import("resource://activity-stream/common/Actions.jsm");
  6. ChromeUtils.defineModuleGetter(this, "setInterval", "resource://gre/modules/Timer.jsm");
  7. ChromeUtils.defineModuleGetter(this, "clearInterval", "resource://gre/modules/Timer.jsm");
  8. // Frequency at which SYSTEM_TICK events are fired
  9. const SYSTEM_TICK_INTERVAL = 5 * 60 * 1000;
  10. this.SystemTickFeed = class SystemTickFeed {
  11. init() {
  12. this.intervalId = setInterval(() => this.store.dispatch({type: at.SYSTEM_TICK}), SYSTEM_TICK_INTERVAL);
  13. }
  14. onAction(action) {
  15. switch (action.type) {
  16. case at.INIT:
  17. this.init();
  18. break;
  19. case at.UNINIT:
  20. clearInterval(this.intervalId);
  21. break;
  22. }
  23. }
  24. };
  25. this.SYSTEM_TICK_INTERVAL = SYSTEM_TICK_INTERVAL;
  26. const EXPORTED_SYMBOLS = ["SystemTickFeed", "SYSTEM_TICK_INTERVAL"];