Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 992969 of ui/id

  • Revision slug: Mozilla/Add-ons/SDK/Low-Level_APIs/ui_id
  • Revision title: ui/id
  • Revision id: 992969
  • Created:
  • Creator: wbamberg
  • Is current revision? Yes
  • Comment

Revision Content

{{AddonSidebar}}

Experimental

Create UI component IDs.

Globals

Functions

identify(object)

Makes and/or gets a unique ID for the input.

Making an ID

const { identify } = require('sdk/ui/id');

const Thingy = Class({
  initialize: function(details) {
    let id = identify(this);
  }
});

Getting an ID

const { identify } = require('sdk/ui/id');
const { Thingy } = require('./thingy');

let thing = Thingy(/* ... */);
let thingID = identify(thing);

Defining ID generator

const { identify } = require('sdk/ui/id');

const Thingy = Class(/* ... */);

identify.define(Thingy, thing => thing.guid);
Parameters

object : Object
Object to create an ID for.

Returns

String : Returns a UUID by default (or domain specific ID based on a provided definition).

Revision Source

{{AddonSidebar}}

<div class="note">
<p>Experimental</p>
</div>

<p><span class="seoSummary">Create UI component IDs.</span></p>

<h2 id="Globals">Globals</h2>

<h3 id="Functions">Functions</h3>

<h4 class="addon-sdk-api-name" id="identify(object)"><code>identify(object)</code></h4>

<p>Makes and/or gets a unique ID for the input.</p>

<p>Making an ID</p>

<pre class="brush: js">
const { identify } = require('sdk/ui/id');

const Thingy = Class({
  initialize: function(details) {
    let id = identify(this);
  }
});</pre>

<p>Getting an ID</p>

<pre class="brush: js">
const { identify } = require('sdk/ui/id');
const { Thingy } = require('./thingy');

let thing = Thingy(/* ... */);
let thingID = identify(thing);</pre>

<p>Defining ID generator</p>

<pre class="brush: js">
const { identify } = require('sdk/ui/id');

const Thingy = Class(/* ... */);

identify.define(Thingy, thing =&gt; thing.guid);</pre>

<h5 id="Parameters">Parameters</h5>

<p><strong>object : Object</strong><br />
 Object to create an ID for.</p>

<h5 id="Returns">Returns</h5>

<p><strong>String</strong> : Returns a UUID by default (or domain specific ID based on a provided definition).</p>
Revert to this revision