mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-29 16:19:43 +08:00
feat: prevent cycle emit in slot (#10539)
This commit is contained in:
@@ -43,4 +43,13 @@ describe('slot', () => {
|
||||
slot.emit();
|
||||
expect(callback).toBeCalledTimes(0);
|
||||
});
|
||||
|
||||
test('cycle emit', () => {
|
||||
const slot = new Slot<number>();
|
||||
const callback = vi.fn(v => slot.emit(v + 1));
|
||||
slot.on(callback);
|
||||
slot.emit(0);
|
||||
expect(callback).toBeCalledTimes(1);
|
||||
expect(callback).toBeCalledWith(0);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user