Open History to see the last commit
1import { InjectionToken, inject } from '@angular/core'
2import * as ng from '@angular/core'
3import { noop } from '@tanstack/query-core'
4β
5type PendingTasksCompat = { add: () => PendingTaskRef }
6β
7export type PendingTaskRef = () => void
8β
9export const PENDING_TASKS = new InjectionToken<PendingTasksCompat>(
10 'PENDING_TASKS',
11 {
12 factory: (): PendingTasksCompat => {
13 // Access via Reflect so bundlers stay quiet when the token is absent (Angular < 19).
14 const token = Reflect.get(ng, 'PendingTasks') as unknown as
15 Parameters<typeof inject>[0] | undefined
16β
17 const svc: PendingTasksCompat | null = token
18 ? (inject(token, { optional: true }) as PendingTasksCompat | null)
19 : null
20β
21 // Without PendingTasks we fall back to a stable no-op shim.
22 return {
23 add: svc ? () => svc.add() : () => noop,
24 }
25 },
26 },
27)