import { debounce } from '@daffodil/core'
A utility decorator that delays method execution until after a specified delay period has elapsed since the last invocation.
function debounce(delay: number = 100): MethodDecorator
| Parameter | delay: number |
|---|---|
| Default | 100 |
| Description | The delay in milliseconds before the method executes. Defaults to 100ms. |
import { debounce } from '@daffodil/core';
class SearchComponent {
@debounce(300)
onSearchInput(value: string) {
// Only executes after 300ms
this.performSearch(value);
}
}
import { debounce } from '@daffodil/core';
class SearchComponent {
@debounce(300)
onSearchInput(value: string) {
// Only executes after 300ms
this.performSearch(value);
}
}
class MyComponent {
@debounce() // Uses 100ms default
onInputChange(value: string) {
console.log('Input changed:', value);
}
}
class MyComponent {
@debounce() // Uses 100ms default
onInputChange(value: string) {
console.log('Input changed:', value);
}
}
import { Component } from '@angular/core';
import { debounce } from '@daffodil/core';
@Component({
selector: 'app-search',
template: '<input (input)="onSearchInput($event.target.value)" />',
})
export class SearchComponent {
@debounce(500)
onSearchInput(value: string) {
this.searchService.search(value);
}
}
import { Component } from '@angular/core';
import { debounce } from '@daffodil/core';
@Component({
selector: 'app-search',
template: '<input (input)="onSearchInput($event.target.value)" />',
})
export class SearchComponent {
@debounce(500)
onSearchInput(value: string) {
this.searchService.search(value);
}
}