Skip to content

Commit ff3f013

Browse files
committed
chore(form-core): update pacer to pacer-lite
1 parent a298ff3 commit ff3f013

File tree

5 files changed

+640
-43
lines changed

5 files changed

+640
-43
lines changed

packages/form-core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
],
5353
"dependencies": {
5454
"@tanstack/devtools-event-client": "^0.3.5",
55-
"@tanstack/pacer": "^0.15.3",
55+
"@tanstack/pacer-lite": "^0.1.0",
5656
"@tanstack/store": "^0.7.7"
5757
},
5858
"devDependencies": {

packages/form-core/src/FormApi.ts

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { Derived, Store, batch } from '@tanstack/store'
2-
import { throttle } from '@tanstack/pacer'
32
import {
43
deleteBy,
54
determineFormLevelErrorSourceAndValue,
@@ -15,13 +14,15 @@ import {
1514
uuid,
1615
} from './utils'
1716
import { defaultValidationLogic } from './ValidationLogic'
18-
1917
import {
2018
isStandardSchemaValidator,
2119
standardSchemaValidators,
2220
} from './standardSchemaValidator'
2321
import { defaultFieldMeta, metaHelper } from './metaHelper'
2422
import { formEventClient } from './EventClient'
23+
import { throttleFormState } from './throttles'
24+
25+
// types
2526
import type { ValidationLogicFn } from './ValidationLogic'
2627
import type {
2728
StandardSchemaV1,
@@ -1304,20 +1305,9 @@ export class FormApi<
13041305

13051306
this.update(opts || {})
13061307

1307-
const debouncedDevtoolState = throttle(
1308-
(state: AnyFormState) =>
1309-
formEventClient.emit('form-state', {
1310-
id: this._formId,
1311-
state: state,
1312-
}),
1313-
{
1314-
wait: 300,
1315-
},
1316-
)
1317-
13181308
// devtool broadcasts
13191309
this.store.subscribe(() => {
1320-
debouncedDevtoolState(this.store.state)
1310+
throttleFormState(this)
13211311
})
13221312

13231313
// devtool requests
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { liteThrottle } from '@tanstack/pacer-lite'
2+
import { formEventClient } from './EventClient'
3+
4+
import type { AnyFormApi } from './FormApi'
5+
6+
export const throttleFormState = liteThrottle(
7+
(form: AnyFormApi) =>
8+
formEventClient.emit('form-state', {
9+
id: form.formId,
10+
state: form.store.state,
11+
}),
12+
{
13+
wait: 300,
14+
},
15+
)

packages/form-core/src/utils.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { defaultValidationLogic } from './ValidationLogic'
21
import type { ValidationLogicProps } from './ValidationLogic'
32
import type { FieldValidators } from './FieldApi'
43
import type { FormValidators } from './FormApi'

0 commit comments

Comments
 (0)