Implement debouncing
Some checks failed
Check usage of free licenses / build-static-assets (pull_request) Successful in 50s
Playwright Tests / test (pull_request) Failing after 54s
Add copyright notice / copyright_notice (pull_request) Successful in 1m5s
Build Nginx-based docker image / build-static-assets (push) Failing after 2m51s
Some checks failed
Check usage of free licenses / build-static-assets (pull_request) Successful in 50s
Playwright Tests / test (pull_request) Failing after 54s
Add copyright notice / copyright_notice (pull_request) Successful in 1m5s
Build Nginx-based docker image / build-static-assets (push) Failing after 2m51s
This commit is contained in:
parent
847666bfc8
commit
0b8a444b39
@ -13,15 +13,25 @@ export default function Page() {
|
||||
const api = new AbstractApi<Website>();
|
||||
const serializer = new WebsiteSerializer();
|
||||
|
||||
const [timeoutId, setTimeoutId] = useState<NodeJS.Timeout | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
api.get(serializer, undefined, (loadedWebsite) => {
|
||||
setWebsite(loadedWebsite);
|
||||
console.log('Website loaded:', loadedWebsite);
|
||||
});
|
||||
}, []);
|
||||
|
||||
const updateWebsite = (newContent: string) => {
|
||||
// Debounce API update: send after 500ms of no further changes
|
||||
if (timeoutId) {
|
||||
clearTimeout(timeoutId);
|
||||
}
|
||||
|
||||
setTimeoutId(
|
||||
setTimeout(() => {
|
||||
api.update(serializer, new Website('', newContent), () => { });
|
||||
}, 500)
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
|
Loading…
x
Reference in New Issue
Block a user