* Schedule a graph run via the transaction-scoped scheduler. * * When called within a transaction, the run is deferred until the * transaction flushes, coalescing multiple changes into a single graph * execution. Without a transaction, the graph runs immediately. * * Dependencies a
(alias?: string)
| 653 | * live query collections, ensuring parent queries run before effects. |
| 654 | */ |
| 655 | private scheduleGraphRun(alias?: string): void { |
| 656 | const contextId = getActiveTransaction()?.id |
| 657 | |
| 658 | // Collect dependencies for this schedule call |
| 659 | const deps = new Set(this.builderDependencies) |
| 660 | if (alias) { |
| 661 | const aliasDeps = this.aliasDependencies[alias] |
| 662 | if (aliasDeps) { |
| 663 | for (const dep of aliasDeps) { |
| 664 | deps.add(dep) |
| 665 | } |
| 666 | } |
| 667 | } |
| 668 | |
| 669 | // Ensure dependent builders are scheduled in this context so that |
| 670 | // dependency edges always point to a real job. |
| 671 | if (contextId) { |
| 672 | for (const dep of deps) { |
| 673 | if ( |
| 674 | typeof dep === `object` && |
| 675 | dep !== null && |
| 676 | `scheduleGraphRun` in dep && |
| 677 | typeof (dep as any).scheduleGraphRun === `function` |
| 678 | ) { |
| 679 | ;(dep as any).scheduleGraphRun(undefined, { contextId }) |
| 680 | } |
| 681 | } |
| 682 | } |
| 683 | |
| 684 | transactionScopedScheduler.schedule({ |
| 685 | contextId, |
| 686 | jobId: this, |
| 687 | dependencies: deps, |
| 688 | run: () => this.executeScheduledGraphRun(), |
| 689 | }) |
| 690 | } |
| 691 | |
| 692 | /** |
| 693 | * Called by the scheduler when dependencies are satisfied. |
no test coverage detected