UNPKG

ember-source

Version:

A JavaScript framework for creating ambitious web applications

69 lines (60 loc) 2 kB
import { g as guidFor } from '../../shared-chunks/super-Cm_a_cLQ.js'; import { g as getName, s as setName } from '../../shared-chunks/name-C68GLLO3.js'; import '../-internals/environment/index.js'; import '../../@glimmer/validator/index.js'; import '../../shared-chunks/reference-BNqcwZWH.js'; import '../../shared-chunks/capabilities-DGmQ_mz4.js'; import { g as get } from '../../shared-chunks/observers-R1ZklwWy.js'; import { N as NAMESPACES, h as NAMESPACES_BY_ID, p as processAllNamespaces, i as findNamespace, j as addNamespace, k as findNamespaces, l as processNamespace, r as removeNamespace } from '../../shared-chunks/namespace_search-Aog9nySA.js'; import EmberObject from '../object/index.js'; /** @module @ember/application/namespace */ /** A Namespace is an object usually used to contain other objects or methods such as an application or framework. Create a namespace anytime you want to define one of these new containers. ## Example Usage ```javascript import Namespace from '@ember/application/namespace'; MyFramework = Namespace.create({ VERSION: '1.0.0' }); ``` @class Namespace @extends EmberObject @public */ class Namespace extends EmberObject { static NAMESPACES = NAMESPACES; static NAMESPACES_BY_ID = NAMESPACES_BY_ID; static processAll = processAllNamespaces; static byName = findNamespace; init(properties) { super.init(properties); addNamespace(this); } toString() { let existing_name = get(this, 'name') || get(this, 'modulePrefix'); if (existing_name) { return existing_name; } findNamespaces(); let name = getName(this); if (name === undefined) { name = guidFor(this); setName(this, name); } return name; } nameClasses() { processNamespace(this); } destroy() { removeNamespace(this); return super.destroy(); } } // Declare on the prototype to have a single shared value. Namespace.prototype.isNamespace = true; export { Namespace as default };