GithubHelp home page GithubHelp logo

Comments (5)

cleidigh avatar cleidigh commented on August 29, 2024

@eyalroz
@thundernest
Services.jsm provides method access to any of the core Thunderbird modules, you could also consider it a new access mechanism replacing the older styles. It provides access to everything from console to preferences. Below is a link to the documentation. Note you can use the services from experiments not background or content scripts.
https://developer.mozilla.org/en-US/docs/Mozilla/JavaScript_code_modules/Services.jsm
@cleidigh

from thunderkdb.

eyalroz avatar eyalroz commented on August 29, 2024

@cleidigh :
But if we use it from within an experiment - i.e. from "regular plain old extension code" - why would we want to access services through Services.jsm, rather than the old way? Let's take one of the first services in there for example: appinfo. We've been writing this:

var appInfo = Components
    .classes["@mozilla.org/xre/app-info;1"]
    .getService(Components.interfaces.nsIXULAppInfo);

and instead we can write this:

const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
var appInfo = Services.appinfo;

granted, it's less verbose. But other than that, what's the benefit?

from thunderkdb.

cleidigh avatar cleidigh commented on August 29, 2024

@eyalroz
Good point. I glossed over that.
First, as you have for longer experience with Thunderbird then I do, using services is how I have been doing pretty much everything. I do not want to speak absolutely authoritatively, however, as I remember when I was starting with code Services.jsm accomplishes two things

  • simplification of code (you pointed out)
  • faster call cycle (I would have to find this as a reference)
    Beyond that I am not sure if there are other benefits.

from thunderkdb.

eyalroz avatar eyalroz commented on August 29, 2024

@cleidigh : More questions:

  1. Is Components.classes going to go away anytime soon though?
  2. When did Services.jsm become available? That is, if we adopt it, at which TB version are we breaking compatibility?
  3. I think at least some of these services are available even without the importation. Like the console. Are there other such examples?

from thunderkdb.

cleidigh avatar cleidigh commented on August 29, 2024

@eyalroz
Hey what do you think I'm some sort of Thunderbird Guru ?? ;-)

1 - For legacy context (60.x and experiments) I think Cc, Ci, Cu still needed as everything is not under services
2 - no idea, again I think it's only relevant for experiments
3 - the JavaScript console yes but services and some of its own functions

from thunderkdb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.