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 509059 of ui/id

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

Revision Content

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

<div class="note">
 <p>Experimental</p>
</div>
<p><span class="seoSummary">Create UI component IDs.</span></p>
<h2>Globals</h2>
<h3>Functions</h3>
<h4 class="addon-sdk-api-name"><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>Parameters</h5>
<p><strong>object : Object</strong><br />
 Object to create an ID for.</p>
<h5>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