@modular-forms/qwik
Version:
The modular and type-safe form library for Qwik
21 lines (20 loc) • 576 B
JavaScript
/**
* Sets the response of the form.
*
* @param form The form of the response.
* @param response The response object.
* @param options The response options.
*/
export function setResponse(form, response, { duration } = {}) {
// Set new response
form.response = response;
// If necessary, remove new response after specified duration if response has
// not been changed in meantime
if (duration) {
setTimeout(() => {
if (form.response === response) {
form.response = {};
}
}, duration);
}
}