This repository has been archived by the owner on Feb 26, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 921202 Adding docs, making default definition for Objects only, a…
…nd using memoize
- Loading branch information
Showing
3 changed files
with
56 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<!-- This Source Code Form is subject to the terms of the Mozilla Public | ||
- License, v. 2.0. If a copy of the MPL was not distributed with this | ||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. --> | ||
|
||
The `ui/id` module provides the `identify` helper method for creating | ||
and defining UI component IDs. | ||
|
||
<api name="identify"> | ||
@function | ||
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); | ||
|
||
@param object {Object} | ||
Object to create an ID for. | ||
@returns {String} | ||
Returns a UUID by default (or domain specific ID based on a provided definition). | ||
</api> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters