How to use the evt.Emitter function in evt

To help you get started, we’ve selected a few evt examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mozilla-b2g / gaia-email-libs-and-more / js / activesync / tasks / sync_refresh.js View on Github external
// -- Exclusively acquire the sync state for the folder
      let fromDb = yield ctx.beginMutate({
        syncStates: new Map([[req.folderId, null]])
      });

      let rawSyncState = fromDb.syncStates.get(req.folderId);
      let syncState = new FolderSyncStateHelper(
        ctx, rawSyncState, req.accountId, req.folderId, 'refresh');

      let account = yield ctx.universe.acquireAccount(ctx, req.accountId);
      let conn = yield account.ensureConnection();

      let folderInfo = account.getFolderById(req.folderId);

      // -- Construct an emitter with our processing logic
      let emitter = new evt.Emitter();
      let newConversations = [];
      let newMessages = [];

      // The id issuing logic is a fundamental part of the 'add'ed message
      // processing.
      let issueIds = () => {
        let umid = syncState.issueUniqueMessageId();
        let convId = req.accountId + '.' + messageIdComponentFromUmid(umid);
        let messageId = convId + '.' + messageIdComponentFromUmid(umid);
        return { messageId, umid, folderId: req.folderId };
      };
      emitter.on('add', (serverMessageId, message) => {
        syncState.newMessage(serverMessageId, message);

        let convId = convIdFromMessageId(message.id);
        newMessages.push(message);
github mozilla-b2g / gaia-email-libs-and-more / js / slog.js View on Github external
define('slog', function(require, exports, module) {
  var $log = require('rdcommon/log');
  var evt = require('evt');

  var logSensitiveData = false;
  exports.setSensitiveDataLoggingEnabled = function(enabled) {
    logSensitiveData = enabled;
    exports.log('meta:sensitive-logging', { enabled: enabled });
  };

  var logEmitter = new evt.Emitter();

  exports.resetEmitter = function() {
    logEmitter = new evt.Emitter();
  };


  var LogChecker = exports.LogChecker = function(T, RT, name) {
    this.T = T;
    this.RT = RT;
    this.eLazy = this.T.lazyLogger(name);
    this.eNotLogLazy = null;
    this._subscribedTo = {};
    this._interceptions = {};
  };
github mozilla-b2g / gaia-email-libs-and-more / js / activesync / tasks / sync_folder_list.js View on Github external
syncFolders: function*(ctx, account) {
      let foldersTOC = account.foldersTOC;
      let conn = yield account.ensureConnection();
      let newFolders = [];
      let modifiedFolders = new Map();

      let fromDb = yield ctx.beginMutate({
        syncStates: new Map([[account.id, null]])
      });

      let rawSyncState = fromDb.syncStates.get(account.id);
      let syncState = new AccountSyncStateHelper(
        ctx, rawSyncState, account.id);

      let emitter = new evt.Emitter();
      let deferredFolders = [];

      function tryAndAddFolder(folderArgs) {
        let maybeFolderInfo = normalizeFolder(
          {
            idMaker: foldersTOC.issueFolderId.bind(syncState),
            serverIdToFolderId: syncState.serverIdToFolderId,
            folderIdToFolderInfo: foldersTOC.foldersById
          },
          {
            serverId: folderArgs.ServerId,
            parentServerId: folderArgs.ParentId,
            displayName: folderArgs.DisplayName,
            typeNum: folderArgs.Type
          }
        );
github mozilla-b2g / gaia-email-libs-and-more / js / slog.js View on Github external
exports.resetEmitter = function() {
    logEmitter = new evt.Emitter();
  };