fast reactive signals jsr.io/@mary/signals
typescript jsr
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

refactor: separate _start method

Mary a6037dd4 c0b53530

+32 -21
+32 -21
mod.ts
··· 514 514 } 515 515 516 516 /** @internal */ 517 - _refresh() { 517 + _start(): (() => void) | undefined { 518 518 const flags = this._flags; 519 519 520 - if (flags & Flags.RUNNING) { 521 - return; 522 - } 523 - 524 520 const prev_listener = eval_listener; 525 521 const prev_sources = eval_untracked_sources; 526 522 const prev_sources_index = eval_sources_index; 527 523 528 - let ret: unknown; 524 + if (flags & Flags.RUNNING) { 525 + return; 526 + } 529 527 530 528 cleanup_effect(this); 531 529 532 - try { 533 - /*#__INLINE__*/ start_batch(); 530 + /*#__INLINE__*/ start_batch(); 534 531 535 - eval_listener = this; 536 - eval_untracked_sources = undefined; 537 - eval_sources_index = 0; 532 + eval_listener = this; 533 + eval_untracked_sources = undefined; 534 + eval_sources_index = 0; 538 535 539 - this._epoch = write_clock; 540 - this._context_epoch = read_clock++; 541 - this._flags = (flags & ~Flags.DISPOSED & ~Flags.DIRTY & ~Flags.MAYBE_DIRTY) | Flags.RUNNING; 536 + this._epoch = write_clock; 537 + this._context_epoch = read_clock++; 538 + this._flags = (flags & ~Flags.DISPOSED & ~Flags.DIRTY & ~Flags.MAYBE_DIRTY) | Flags.RUNNING; 542 539 543 - ret = this._compute(); 544 - 545 - if (typeof ret === 'function') { 546 - this._cleanup = ret as (() => unknown); 547 - } 548 - } finally { 540 + return () => { 549 541 cleanup_context(); 550 542 551 543 eval_listener = prev_listener; 552 544 eval_untracked_sources = prev_sources; 553 545 eval_sources_index = prev_sources_index; 546 + 547 + end_batch(); 554 548 555 549 if ((this._flags &= ~Flags.RUNNING) & Flags.DISPOSED) { 556 550 dispose_effect(this, true); 557 551 } 552 + }; 553 + } 558 554 559 - end_batch(); 555 + /** @internal */ 556 + _refresh(): void { 557 + const finish = this._start(); 558 + 559 + if (!finish) { 560 + return; 561 + } 562 + 563 + try { 564 + const ret = this._compute(); 565 + 566 + if (typeof ret === 'function') { 567 + this._cleanup = ret as (() => void); 568 + } 569 + } finally { 570 + finish(); 560 571 } 561 572 } 562 573