本文整理汇总了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;
}