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
6ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
7
8const {actionTypes: at} = ChromeUtils.import("resource://activity-stream/common/Actions.jsm", {});
9
10ChromeUtils.defineModuleGetter(this, "setInterval", "resource://gre/modules/Timer.jsm");
11ChromeUtils.defineModuleGetter(this, "clearInterval", "resource://gre/modules/Timer.jsm");
12
13// Frequency at which SYSTEM_TICK events are fired
14const SYSTEM_TICK_INTERVAL = 5 * 60 * 1000;
15
16this.SystemTickFeed = class SystemTickFeed {
17  init() {
18    this.intervalId = setInterval(() => this.store.dispatch({type: at.SYSTEM_TICK}), SYSTEM_TICK_INTERVAL);
19  }
20
21  onAction(action) {
22    switch (action.type) {
23      case at.INIT:
24        this.init();
25        break;
26      case at.UNINIT:
27        clearInterval(this.intervalId);
28        break;
29    }
30  }
31};
32
33this.SYSTEM_TICK_INTERVAL = SYSTEM_TICK_INTERVAL;
34const EXPORTED_SYMBOLS = ["SystemTickFeed", "SYSTEM_TICK_INTERVAL"];
35