feature/searchbar-enhance #17
@@ -14,7 +14,8 @@ export function createDebouncedState<T>(initialValue: T, wait: number = 300) {
|
||||
},
|
||||
set immediate(value: T) {
|
||||
immediate = value;
|
||||
updateDebounced(value); // Manually trigger the debounce on write
|
||||
// Manually trigger the debounce on write
|
||||
updateDebounced(value);
|
||||
},
|
||||
get debounced() {
|
||||
return debounced;
|
||||
@@ -26,33 +27,3 @@ export function createDebouncedState<T>(initialValue: T, wait: number = 300) {
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
// export function createDebouncedState<T>(initialValue: T, wait: number = 300) {
|
||||
// let immediate = $state(initialValue);
|
||||
// let debounced = $state(initialValue);
|
||||
|
||||
// const updateDebounced = debounce((value: T) => {
|
||||
// debounced = value;
|
||||
// }, wait);
|
||||
|
||||
// $effect(() => {
|
||||
// updateDebounced(immediate);
|
||||
// });
|
||||
|
||||
// return {
|
||||
// get immediate() {
|
||||
// return immediate;
|
||||
// },
|
||||
// set immediate(value: T) {
|
||||
// immediate = value;
|
||||
// },
|
||||
// get debounced() {
|
||||
// return debounced;
|
||||
// },
|
||||
// reset(value?: T) {
|
||||
// const resetValue = value ?? initialValue;
|
||||
// immediate = resetValue;
|
||||
// debounced = resetValue;
|
||||
// },
|
||||
// };
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user