Skip to content

Instantly share code, notes, and snippets.

@freaktechnik
Last active April 26, 2024 22:11
Show Gist options
  • Select an option

  • Save freaktechnik/96487f9dbbecf693017fd11928bf0056 to your computer and use it in GitHub Desktop.

Select an option

Save freaktechnik/96487f9dbbecf693017fd11928bf0056 to your computer and use it in GitHub Desktop.
"use strict";
// Require some stuff
const { myMethod } = require("my-method");
// Init code
myMethod("initializing");
...
// Cleaning up
exports.onUnload = () => {
// Do cleanup
};
"use strict";
// Require some stuff
const { when: unload } = require("sdk/system/unload");
// Init code
const MY_CONSTANT = "foo";
// Exports (there are multiple way to organize these, some like to define then export, some prefer to directly export)
exports.aMethod = () => MY_CONSTANT;
// Unload
unload(() => {
// Clean up the mess this module made.
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment