本文整理匯總了TypeScript中@ember/object/internals.guidFor函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript guidFor函數的具體用法?TypeScript guidFor怎麽用?TypeScript guidFor使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了guidFor函數的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: guidFor
const unload = inverseRecordData => {
const id = guidFor(inverseRecordData);
if (this._hasSupportForRelationships(inverseRecordData) && seen[id] === undefined) {
const relationship = relationshipStateFor(inverseRecordData, this.inverseKey);
relationship.removeCompletelyFromOwn(recordData);
seen[id] = true;
}
};
示例2: guidFor
.finally(() => {
let contextGuid = guidFor(context);
runDestroyablesFor(CLEANUP, contextGuid);
if (waitForSettled) {
return settled();
}
return nextTickPromise();
});
示例3: nextTickPromise
return nextTickPromise().then(() => {
let contextGuid = guidFor(context);
runDestroyablesFor(RENDERING_CLEANUP, contextGuid);
if (waitForSettled) {
return settled();
}
return nextTickPromise();
});
示例4: forAllMembers
forAllMembers(callback: (im: RelationshipRecordData) => void) {
let seen = Object.create(null);
for (let i = 0; i < this.members.list.length; i++) {
const inverseInternalModel = this.members.list[i];
const id = guidFor(inverseInternalModel);
if (!seen[id]) {
seen[id] = true;
callback(inverseInternalModel);
}
}
for (let i = 0; i < this.canonicalMembers.list.length; i++) {
const inverseInternalModel = this.canonicalMembers.list[i];
const id = guidFor(inverseInternalModel);
if (!seen[id]) {
seen[id] = true;
callback(inverseInternalModel);
}
}
}
示例5: addWithIndex
addWithIndex(obj: T, idx?: number) {
let guid = guidFor(obj);
let presenceSet = this.presenceSet;
let list = this.list;
if (presenceSet[guid] === true) {
return;
}
presenceSet[guid] = true;
if (idx === undefined || idx === null) {
list.push(obj);
} else {
list.splice(idx, 0, obj);
}
this.size += 1;
return this;
}
示例6: container
/**
Used by test framework addons to setup the provided context for rendering.
`setupContext` must have been ran on the provided context
prior to calling `setupRenderingContext`.
Responsible for:
- Setup the basic framework used for rendering by the
`render` helper.
- Ensuring the event dispatcher is properly setup.
- Setting `this.element` to the root element of the testing
container (things rendered via `render` will go _into_ this
element).
@public
@param {Object} context the context to setup for rendering
@returns {Promise<Object>} resolves with the context that was setup
*/
export default function setupRenderingContext(context: TestContext): Promise<RenderingTestContext> {
let contextGuid = guidFor(context);
RENDERING_CLEANUP[contextGuid] = [];
return nextTickPromise()
.then(() => {
let { owner } = context;
// these methods being placed on the context itself will be deprecated in
// a future version (no giant rush) to remove some confusion about which
// is the "right" way to things...
Object.defineProperty(context, 'render', {
configurable: true,
enumerable: true,
value: render,
writable: false,
});
Object.defineProperty(context, 'clearRender', {
configurable: true,
enumerable: true,
value: clearRender,
writable: false,
});
if (global.jQuery) {
Object.defineProperty(context, '$', {
configurable: true,
enumerable: true,
value: jQuerySelector,
writable: false,
});
}
// When the host app uses `setApplication` (instead of `setResolver`) the event dispatcher has
// already been setup via `applicationInstance.boot()` in `./build-owner`. If using
// `setResolver` (instead of `setApplication`) a "mock owner" is created by extending
// `Ember._ContainerProxyMixin` and `Ember._RegistryProxyMixin` in this scenario we need to
// manually start the event dispatcher.
if (owner._emberTestHelpersMockOwner) {
let dispatcher =
owner.lookup('event_dispatcher:main') || (Ember.EventDispatcher as any).create();
dispatcher.setup({}, '#ember-testing');
}
let OutletView = owner.factoryFor
? owner.factoryFor('view:-outlet')
: owner._lookupFactory!('view:-outlet');
let toplevelView = OutletView.create();
owner.register('-top-level-view:main', {
create() {
return toplevelView;
},
});
// initially render a simple empty template
return render(EMPTY_TEMPLATE).then(() => {
(run as Function)(toplevelView, 'appendTo', getRootElement());
return settled();
});
})
.then(() => {
Object.defineProperty(context, 'element', {
configurable: true,
enumerable: true,
// ensure the element is based on the wrapping toplevel view
// Ember still wraps the main application template with a
// normal tagged view
//
// In older Ember versions (2.4) the element itself is not stable,
// and therefore we cannot update the `this.element` until after the
// rendering is completed
value:
global.EmberENV._APPLICATION_TEMPLATE_WRAPPER !== false
? getRootElement().querySelector('.ember-view')
: getRootElement(),
writable: false,
});
//.........這裏部分代碼省略.........
示例7: carouselName
@computed
get carouselName() : string {
return guidFor(this) + '-carousel';
}
示例8: context
/**
Used by test framework addons to setup the provided context for testing.
Responsible for:
- sets the "global testing context" to the provided context (`setContext`)
- create an owner object and set it on the provided context (e.g. `this.owner`)
- setup `this.set`, `this.setProperties`, `this.get`, and `this.getProperties` to the provided context
- setting up AJAX listeners
- setting up `pauseTest` (also available as `this.pauseTest()`) and `resumeTest` helpers
@public
@param {Object} context the context to setup
@param {Object} [options] options used to override defaults
@param {Resolver} [options.resolver] a resolver to use for customizing normal resolution
@returns {Promise<Object>} resolves with the context that was setup
*/
export default function setupContext(
context: BaseContext,
options: { resolver?: Resolver } = {}
): Promise<TestContext> {
(Ember as any).testing = true;
setContext(context);
let contextGuid = guidFor(context);
CLEANUP[contextGuid] = [];
run.backburner.DEBUG = true;
return nextTickPromise()
.then(() => {
let application = getApplication();
if (application) {
return application.boot().then(() => {});
}
return;
})
.then(() => {
let testElementContainer = document.getElementById('ember-testing-container')!; // TODO remove "!"
let fixtureResetValue = testElementContainer.innerHTML;
// push this into the final cleanup bucket, to be ran _after_ the owner
// is destroyed and settled (e.g. flushed run loops, etc)
CLEANUP[contextGuid].push(() => {
testElementContainer.innerHTML = fixtureResetValue;
});
let { resolver } = options;
// This handles precendence, specifying a specific option of
// resolver always trumps whatever is auto-detected, then we fallback to
// the suite-wide registrations
//
// At some later time this can be extended to support specifying a custom
// engine or application...
if (resolver) {
return buildOwner(null, resolver);
}
return buildOwner(getApplication(), getResolver());
})
.then(owner => {
Object.defineProperty(context, 'owner', {
configurable: true,
enumerable: true,
value: owner,
writable: false,
});
Object.defineProperty(context, 'set', {
configurable: true,
enumerable: true,
value(key: string, value: any): any {
let ret = run(function() {
return set(context, key, value);
});
return ret;
},
writable: false,
});
Object.defineProperty(context, 'setProperties', {
configurable: true,
enumerable: true,
value(hash: { [key: string]: any }): { [key: string]: any } {
let ret = run(function() {
return setProperties(context, hash);
});
return ret;
},
writable: false,
});
Object.defineProperty(context, 'get', {
configurable: true,
enumerable: true,
value(key: string): any {
return get(context, key);
//.........這裏部分代碼省略.........