How to use the evt.emit 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 / apps / email / js / sync.js View on Github external
function finishSync() {
        evt.emit('cronSyncStop', accountsResults.accountIds);

        // Mark this accountId set as no longer waiting.
        var accountKey = makeAccountKey(accountsResults.accountIds);
        waitingOnCron[accountKey] = false;
        var stillWaiting = Object.keys(waitingOnCron).some(function(key) {
          return !!waitingOnCron[key];
        });

        if (!hasBeenVisible && !stillWaiting) {
          var msg = 'mail sync complete, closing mail app';
          if (typeof plog === 'function') {
            plog(msg);
          } else {
            console.log(msg);
          }
github mozilla-b2g / gaia / apps / email / js / cards / message_list.js View on Github external
this.msgVScroll.on('messagesComplete', function(newEmailCount) {
        this.onNewMail(newEmailCount);

        // Inform that content is ready. There could actually be a small delay
        // with vScroll.updateDataBind from rendering the final display, but it
        // is small enough that it is not worth trying to break apart the design
        // to accommodate this metrics signal.
        if (!this._emittedContentEvents) {
          evt.emit('metrics:contentDone');
          this._emittedContentEvents = true;
        }
      }.bind(this));
github mozilla-b2g / gaia / apps / email / js / cards / message_list.js View on Github external
onFolderShown: function() {
      var model = this.model,
          account = model.account,
          foldersSlice = model.foldersSlice;

      // The extra checks here are to allow for lazy startup when we might have
      // a card instance but not a full model available. Once the model is
      // available though, this method will get called again, so the event
      // emitting is still correctly done in the lazy startup case.
      if (!document.hidden && account && foldersSlice && this.curFolder) {
        var inboxFolder = foldersSlice.getFirstFolderWithType('inbox');
        if (inboxFolder === this.curFolder) {
          evt.emit('inboxShown', account.id);
        }

        // If user tapped in search box on message_list before the JS for the
        // card is attached, then treat that as the signal to go to search. Only
        // do this when first starting up though.
        if (document.activeElement === this.searchTextTease) {
          this.onSearchButton();
        }
      }
    },
github mozilla-b2g / gaia / apps / email / js / cards / message_reader.js View on Github external
enableReply: function() {
      var btn = this.querySelector('.msg-reply-btn');
      btn.removeAttribute('aria-disabled');

      // Inform that content is ready. Done here because reply is only enabled
      // once the full body is available.
      if (!this._emittedContentEvents) {
        evt.emit('metrics:contentDone');
        this._emittedContentEvents = true;
      }
    },
github mozilla-b2g / gaia / apps / email / js / cards / setup_done.js View on Github external
onShowMail: function() {
      // Nuke this card
      evt.emit('showLatestAccount');
    },
github mozilla-b2g / gaia / apps / email / js / cards / compose.js View on Github external
this.composer.finishCompositionSendMessage(function(sendInfo) {
        evt.emit('uiDataOperationStop', this._dataIdSendEmail);

        // Card could have been destroyed in the meantime,
        // via an app card reset (not a _selfClosed case),
        // so do not bother with the rest of this work if
        // that was the case.
        if (!this.composer) {
          return;
        }

        if (activity) {
          // Just mention the action completed, but do not give
          // specifics, to maintain some privacy.
          activity.postResult('complete');
          activity = null;
        }
github mozilla-b2g / gaia / apps / email / js / mail_common.js View on Github external
_emitStartupEvents: function(skipEmitContentEvents) {
    if (!this._startupEventsEmitted) {
      if (startupCacheEventsSent) {
        // Cache already loaded, so at this point the content shown is wired
        // to event handlers.
        window.dispatchEvent(new CustomEvent('moz-content-interactive'));
      } else {
        // Cache was not used, so only now is the chrome dom loaded.
        window.dispatchEvent(new CustomEvent('moz-chrome-dom-loaded'));
      }
      window.dispatchEvent(new CustomEvent('moz-chrome-interactive'));

      // If a card that has a simple static content DOM, content is complete.
      // Otherwise, like message_list, need backend data to call complete.
      if (!skipEmitContentEvents) {
        evt.emit('metrics:contentDone');
      }

      this._startupEventsEmitted = true;
    }
  },
github mozilla-b2g / gaia / apps / email / js / cards / setup_done.js View on Github external
onAddAnother: function() {
      evt.emit('addAccount');
    },
    onShowMail: function() {
github mozilla-b2g / gaia / apps / email / js / cards / folder_picker.js View on Github external
_closeCard: function() {
      evt.emit('folderPickerClosing');
      this.classList.remove('opened');
    },
github mozilla-b2g / gaia / apps / email / js / cards / compose.js View on Github external
this.composer.saveDraft(function() {
        evt.emit('uiDataOperationStop', this._dataIdSaveDraft);
        if (callback) {
          callback();
        }
      }.bind(this));
    },