-
-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathinputapp.ts
More file actions
26 lines (23 loc) · 769 Bytes
/
inputapp.ts
File metadata and controls
26 lines (23 loc) · 769 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { Component, input } from '@angular/core'
import { injectQueuedValue } from '@tanstack/angular-pacer'
@Component({
selector: 'app-input',
standalone: true,
template: `
<h1>NG0950</h1>
<p>value: {{ value() }}</p>
<p>Value (queued): {{ queued() }}</p>
<p>Queue length: {{ queued.queuer.state().items.length }}</p>
<button (click)="enqueueRandom()">Enqueue random</button>
`,
})
export class InputApp {
readonly value = input.required<string>()
protected readonly queued = injectQueuedValue(this.value, null, { wait: 500 }, (state) => ({
items: state.items,
}))
protected enqueueRandom(): void {
// You can also enqueue values directly without touching `source`
this.queued.addItem(Math.random().toFixed(4))
}
}