本文整理匯總了TypeScript中@aurelia/runtime.ILifecycle類的典型用法代碼示例。如果您正苦於以下問題:TypeScript ILifecycle類的具體用法?TypeScript ILifecycle怎麽用?TypeScript ILifecycle使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了ILifecycle類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: describe
describe('ClassAccessor', function () {
let sut: ClassAttributeAccessor;
let el: HTMLElement;
let lifecycle: ILifecycle;
let initialClassList: string;
const markupArr = [
'<div></div>',
'<div class=""></div>',
'<div class="foo"></div>',
'<div class="foo bar baz"></div>'
];
const classListArr = ['', 'foo', 'foo bar', 'bar baz', 'qux', 'bar qux', 'qux quux'];
const secondClassListArr = ['', 'fooo'];
for (const markup of markupArr) {
for (const classList of classListArr) {
beforeEach(function () {
const ctx = TestContext.createHTMLTestContext();
el = ctx.createElementFromMarkup(markup);
initialClassList = el.classList.toString();
const { lifecycle: $lifecycle } = setup();
lifecycle = $lifecycle;
sut = new ClassAttributeAccessor(lifecycle, el);
});
it(`setValue("${classList}") updates ${markup}`, function () {
sut.setValue(classList, LifecycleFlags.none);
expect(el.classList.toString()).to.equal(initialClassList);
lifecycle.processFlushQueue(LifecycleFlags.none);
const updatedClassList = el.classList.toString();
for (const cls of initialClassList.split(' ')) {
expect(updatedClassList).to.contain(cls);
}
for (const cls of classList.split(' ')) {
expect(updatedClassList).to.contain(cls);
}
});
for (const secondClassList of secondClassListArr) {
it(`setValue("${secondClassList}") updates already-updated ${markup}`, function () {
sut.setValue(classList, LifecycleFlags.none);
lifecycle.processFlushQueue(LifecycleFlags.none);
const updatedClassList = el.classList.toString();
sut.setValue(secondClassList, LifecycleFlags.none);
expect(el.classList.toString()).to.equal(updatedClassList);
lifecycle.processFlushQueue(LifecycleFlags.none);
const secondUpdatedClassList = el.classList.toString();
for (const cls of initialClassList.split(' ')) {
if (!classList.includes(cls)) {
expect(secondUpdatedClassList).to.contain(cls);
}
}
for (const cls of secondClassList.split(' ')) {
expect(secondUpdatedClassList).to.contain(cls);
}
});
}
}
}
});
示例2: it
it(`setValue("${secondClassList}") updates already-updated ${markup}`, function () {
sut.setValue(classList, LifecycleFlags.none);
lifecycle.processFlushQueue(LifecycleFlags.none);
const updatedClassList = el.classList.toString();
sut.setValue(secondClassList, LifecycleFlags.none);
expect(el.classList.toString()).to.equal(updatedClassList);
lifecycle.processFlushQueue(LifecycleFlags.none);
const secondUpdatedClassList = el.classList.toString();
for (const cls of initialClassList.split(' ')) {
if (!classList.includes(cls)) {
expect(secondUpdatedClassList).to.contain(cls);
}
}
for (const cls of secondClassList.split(' ')) {
expect(secondUpdatedClassList).to.contain(cls);
}
});
示例3:
public $detach(): void {
this.$lifecycle.enqueueUnmount(this);
this.$state &= ~State.isAttached;
}