How to use unload - 10 common examples

To help you get started, we’ve selected a few unload 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 faradayio / careplane / moz-addon-sdk / packages / development-mode / lib / bootstrap.js View on Github external
try {
    harnessService = factory.createInstance(null, Ci.nsISupports);
    harnessService = harnessService.wrappedJSObject;
    gServices[contractID] = harnessService;
    harnessService.load();
    return makeUnloader(contractID, classID);
  } catch (e) {
    console.exception(e);
    return null;
  }
};

// When this module is unloaded, shut down all currently-running
// Jetpack Programs we manage and free their resources.
require("unload").when(
  function() {
    var argLists = [];
    for (contractID in gServices)
      argLists.push([contractID, gServices[contractID].classID]);

    argLists.forEach(
      function(args) {
        maybeUnload.apply(undefined, args);
      });
  });
github Gozala / sky-edit / main.js View on Github external
onRequest: function(request, response) {
    try {
      // All the editor content is located under 'edit:///' so to get a path
      // we just strip that out.
      var path = request.uri.replace('edit:///', '')
      // If requested path was diff from 'edit:///...', then we load editor.
      path = ~path.indexOf('edit:') ? 'index.html' : path
      response.uri = data.url(path)
    } catch(error) {
      console.exception(error)
    }
  }
}).register()

// Make suer that protocol handler is removed, once add-on is uninstalled.
require("unload").when(function() {
  editProtocolHandler.unregister()
})

});
github kriskowal / narwhal-lib / engines / default / lib / reactor.js View on Github external
// Kris Kowal

var tasks = [];

require('unload').when(function () {
    while (tasks.length)
        tasks.shift()();
});

exports.enqueue = function (task) {
    tasks.push(task);
};
github kriskowal / narwhal-lib / engines / rhino / lib / event-loop-engine.js View on Github external
// -- kriszyp Kris Zyp

/**
 * Represents the event queue for a vat
 * The API is modeled after https://developer.mozilla.org/en/nsIThread
 */

// we could eventually upgrade to PriorityBlockingQueye with FIFOEntry tie breaking
var loopLevel = 0,
    shuttingDown, 
    queue = new java.util.concurrent.LinkedBlockingQueue();

require("unload").when(function () {
    if (exports.hasPendingEvents())
        exports.enterEventLoop(function () {
            exports.shutdown();
        });
});

exports.getNextEvent = function(){
    return queue.take();
};

exports.processNextEvent = function(mayWait){
    if(!mayWait && queue.isEmpty()){
        return false;
    }
    try{
        var next = queue.take();
github clarkbw / addon-pathfinder / lib / userstyles.js View on Github external
exports.load = function load(aURL) {
  let sss = Cc["@mozilla.org/content/style-sheet-service;1"]
      .getService(Ci.nsIStyleSheetService);
  let uri = Cc["@mozilla.org/network/io-service;1"]
      .getService(Ci.nsIIOService).newURI(aURL, null, null);

  // load the stylesheet
  sss.loadAndRegisterSheet(uri, sss.USER_SHEET);

  // unload the stylesheet on unload
  unload(function() {
    sss.unregisterSheet(uri, sss.USER_SHEET);
  });
}
github mozilla / browserid_addon / addon / lib / vep.js View on Github external
// Clean up any channel display from the content area
  browser.browserIdCleanUp = function() {
    browser.browserIdCleanUp = function() {};

    // Trigger the callback if it's still waiting
    callback();

    observer.remove("document-element-inserted", injectController);
    promptBox.parentNode.removeChild(promptBox);
    browser.browserIdActive = false;
    window.browserId.updateSignIn();
  };

  // Remove any active channel bits
  unload.when(function() {
    browser.browserIdCleanUp();
  });
}
github mozilla / prospector / recallMonkey / lib / main.js View on Github external
onPress: function() {
    recall();
  }
});


function handleUnload(reason) {
  console.log(reason);
  let bmsvc = Cc["@mozilla.org/browser/nav-bookmarks-service;1"]
              .getService(Ci.nsINavBookmarksService);
  let ios = Cc["@mozilla.org/network/io-service;1"]
            .getService(Ci.nsIIOService);
  let bid = ss.storage.bookmarkId;
  bmsvc.removeItem(bid);
}
unload.when(handleUnload);
github mozilla / fx-share-addon / lib / main.js View on Github external
exports.main = function(options, callbacks) {
  unload.when(shutdown);
  getString.init();
  let owa = require("openwebapps/main");
  return;
};
github mozilla / chromeless / modules / lib / xhr.js View on Github external
function(name) {
     XMLHttpRequest.prototype.__defineGetter__(
       name,
       function() {
         return this._req[name];
       });
   });

DELEGATED_METHODS.forEach(
  function(name) {
    XMLHttpRequest.prototype[name] = function() {
      return this._req[name].apply(this._req, arguments);
    };
  });

require("unload").when(
  function() {
    requests.slice().forEach(function(request) { request._unload(); });
  });
github clarkbw / addon-pathfinder / lib / devtools / gcli.js View on Github external
function addCommand(cmd) {
  let name = cmd.name;
  gcli.addCommand(cmd);
  unload(gcli.removeCommand.bind(gcli, name));
}
exports.addCommand = addCommand;

unload

Execute code when the js-process exits. On all javascript-environments

Apache-2.0
Latest version published 1 year ago

Package Health Score

76 / 100
Full package analysis

Popular unload functions