@tanstack/preact-pacer 0.21.1 → 0.22.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/async-batcher/useAsyncBatchedCallback.cjs.map +1 -1
- package/dist/async-batcher/useAsyncBatchedCallback.js.map +1 -1
- package/dist/async-batcher/useAsyncBatcher.cjs +2 -2
- package/dist/async-batcher/useAsyncBatcher.cjs.map +1 -1
- package/dist/async-batcher/useAsyncBatcher.d.cts +2 -2
- package/dist/async-batcher/useAsyncBatcher.d.ts +2 -2
- package/dist/async-batcher/useAsyncBatcher.js +3 -3
- package/dist/async-batcher/useAsyncBatcher.js.map +1 -1
- package/dist/async-debouncer/useAsyncDebouncedCallback.cjs.map +1 -1
- package/dist/async-debouncer/useAsyncDebouncedCallback.js.map +1 -1
- package/dist/async-debouncer/useAsyncDebouncer.cjs +2 -2
- package/dist/async-debouncer/useAsyncDebouncer.cjs.map +1 -1
- package/dist/async-debouncer/useAsyncDebouncer.d.cts +2 -2
- package/dist/async-debouncer/useAsyncDebouncer.d.ts +2 -2
- package/dist/async-debouncer/useAsyncDebouncer.js +3 -3
- package/dist/async-debouncer/useAsyncDebouncer.js.map +1 -1
- package/dist/async-queuer/useAsyncQueuedState.cjs.map +1 -1
- package/dist/async-queuer/useAsyncQueuedState.js.map +1 -1
- package/dist/async-queuer/useAsyncQueuer.cjs +2 -2
- package/dist/async-queuer/useAsyncQueuer.cjs.map +1 -1
- package/dist/async-queuer/useAsyncQueuer.d.cts +2 -2
- package/dist/async-queuer/useAsyncQueuer.d.ts +2 -2
- package/dist/async-queuer/useAsyncQueuer.js +3 -3
- package/dist/async-queuer/useAsyncQueuer.js.map +1 -1
- package/dist/async-rate-limiter/useAsyncRateLimitedCallback.cjs.map +1 -1
- package/dist/async-rate-limiter/useAsyncRateLimitedCallback.js.map +1 -1
- package/dist/async-rate-limiter/useAsyncRateLimiter.cjs +2 -2
- package/dist/async-rate-limiter/useAsyncRateLimiter.cjs.map +1 -1
- package/dist/async-rate-limiter/useAsyncRateLimiter.d.cts +2 -2
- package/dist/async-rate-limiter/useAsyncRateLimiter.d.ts +2 -2
- package/dist/async-rate-limiter/useAsyncRateLimiter.js +3 -3
- package/dist/async-rate-limiter/useAsyncRateLimiter.js.map +1 -1
- package/dist/async-throttler/useAsyncThrottledCallback.cjs.map +1 -1
- package/dist/async-throttler/useAsyncThrottledCallback.js.map +1 -1
- package/dist/async-throttler/useAsyncThrottler.cjs +2 -2
- package/dist/async-throttler/useAsyncThrottler.cjs.map +1 -1
- package/dist/async-throttler/useAsyncThrottler.d.cts +2 -2
- package/dist/async-throttler/useAsyncThrottler.d.ts +2 -2
- package/dist/async-throttler/useAsyncThrottler.js +3 -3
- package/dist/async-throttler/useAsyncThrottler.js.map +1 -1
- package/dist/batcher/useBatchedCallback.cjs.map +1 -1
- package/dist/batcher/useBatchedCallback.js.map +1 -1
- package/dist/batcher/useBatcher.cjs +2 -2
- package/dist/batcher/useBatcher.cjs.map +1 -1
- package/dist/batcher/useBatcher.d.cts +2 -2
- package/dist/batcher/useBatcher.d.ts +2 -2
- package/dist/batcher/useBatcher.js +3 -3
- package/dist/batcher/useBatcher.js.map +1 -1
- package/dist/debouncer/useDebouncedCallback.cjs.map +1 -1
- package/dist/debouncer/useDebouncedCallback.js.map +1 -1
- package/dist/debouncer/useDebouncedState.cjs.map +1 -1
- package/dist/debouncer/useDebouncedState.js.map +1 -1
- package/dist/debouncer/useDebouncedValue.cjs.map +1 -1
- package/dist/debouncer/useDebouncedValue.js.map +1 -1
- package/dist/debouncer/useDebouncer.cjs +2 -2
- package/dist/debouncer/useDebouncer.cjs.map +1 -1
- package/dist/debouncer/useDebouncer.d.cts +2 -2
- package/dist/debouncer/useDebouncer.d.ts +2 -2
- package/dist/debouncer/useDebouncer.js +3 -3
- package/dist/debouncer/useDebouncer.js.map +1 -1
- package/dist/provider/PacerProvider.cjs.map +1 -1
- package/dist/provider/PacerProvider.js.map +1 -1
- package/dist/queuer/useQueuedState.cjs.map +1 -1
- package/dist/queuer/useQueuedState.js.map +1 -1
- package/dist/queuer/useQueuedValue.cjs.map +1 -1
- package/dist/queuer/useQueuedValue.js.map +1 -1
- package/dist/queuer/useQueuer.cjs +2 -2
- package/dist/queuer/useQueuer.cjs.map +1 -1
- package/dist/queuer/useQueuer.d.cts +2 -2
- package/dist/queuer/useQueuer.d.ts +2 -2
- package/dist/queuer/useQueuer.js +3 -3
- package/dist/queuer/useQueuer.js.map +1 -1
- package/dist/rate-limiter/useRateLimitedCallback.cjs.map +1 -1
- package/dist/rate-limiter/useRateLimitedCallback.js.map +1 -1
- package/dist/rate-limiter/useRateLimitedState.cjs.map +1 -1
- package/dist/rate-limiter/useRateLimitedState.js.map +1 -1
- package/dist/rate-limiter/useRateLimitedValue.cjs.map +1 -1
- package/dist/rate-limiter/useRateLimitedValue.js.map +1 -1
- package/dist/rate-limiter/useRateLimiter.cjs +2 -2
- package/dist/rate-limiter/useRateLimiter.cjs.map +1 -1
- package/dist/rate-limiter/useRateLimiter.d.cts +2 -2
- package/dist/rate-limiter/useRateLimiter.d.ts +2 -2
- package/dist/rate-limiter/useRateLimiter.js +3 -3
- package/dist/rate-limiter/useRateLimiter.js.map +1 -1
- package/dist/throttler/useThrottledCallback.cjs.map +1 -1
- package/dist/throttler/useThrottledCallback.js.map +1 -1
- package/dist/throttler/useThrottledState.cjs.map +1 -1
- package/dist/throttler/useThrottledState.js.map +1 -1
- package/dist/throttler/useThrottledValue.cjs.map +1 -1
- package/dist/throttler/useThrottledValue.js.map +1 -1
- package/dist/throttler/useThrottler.cjs +2 -2
- package/dist/throttler/useThrottler.cjs.map +1 -1
- package/dist/throttler/useThrottler.d.cts +2 -2
- package/dist/throttler/useThrottler.d.ts +2 -2
- package/dist/throttler/useThrottler.js +3 -3
- package/dist/throttler/useThrottler.js.map +1 -1
- package/package.json +5 -5
- package/src/async-batcher/useAsyncBatcher.ts +6 -6
- package/src/async-debouncer/useAsyncDebouncer.ts +8 -6
- package/src/async-queuer/useAsyncQueuer.ts +6 -6
- package/src/async-rate-limiter/useAsyncRateLimiter.ts +8 -6
- package/src/async-throttler/useAsyncThrottler.ts +8 -6
- package/src/batcher/useBatcher.ts +6 -6
- package/src/debouncer/useDebouncer.ts +6 -6
- package/src/queuer/useQueuer.ts +6 -6
- package/src/rate-limiter/useRateLimiter.ts +6 -6
- package/src/throttler/useThrottler.ts +6 -6
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useEffect, useMemo, useState } from 'preact/hooks'
|
|
2
2
|
import { AsyncThrottler } from '@tanstack/pacer/async-throttler'
|
|
3
|
-
import { shallow,
|
|
3
|
+
import { shallow, useSelector } from '@tanstack/preact-store'
|
|
4
4
|
import { useDefaultPacerOptions } from '../provider/PacerProvider'
|
|
5
5
|
import type { Store } from '@tanstack/preact-store'
|
|
6
6
|
import type { AnyAsyncFunction } from '@tanstack/pacer/types'
|
|
@@ -50,8 +50,8 @@ export interface PreactAsyncThrottler<
|
|
|
50
50
|
readonly state: Readonly<TSelected>
|
|
51
51
|
/**
|
|
52
52
|
* @deprecated Use `throttler.state` instead of `throttler.store.state` if you want to read reactive state.
|
|
53
|
-
* The state on the store object is not reactive, as it has not been wrapped in a `
|
|
54
|
-
* Although, you can make the state reactive by using the `
|
|
53
|
+
* The state on the store object is not reactive, as it has not been wrapped in a `useSelector` hook internally.
|
|
54
|
+
* Although, you can make the state reactive by using the `useSelector` in your own usage.
|
|
55
55
|
*/
|
|
56
56
|
readonly store: Store<Readonly<AsyncThrottlerState<TFn>>>
|
|
57
57
|
}
|
|
@@ -242,8 +242,8 @@ export function useAsyncThrottler<TFn extends AnyAsyncFunction, TSelected = {}>(
|
|
|
242
242
|
selector: (state: AsyncThrottlerState<TFn>) => TSelected
|
|
243
243
|
children: ((state: TSelected) => ComponentChildren) | ComponentChildren
|
|
244
244
|
}) {
|
|
245
|
-
const selected =
|
|
246
|
-
|
|
245
|
+
const selected = useSelector(throttlerInstance.store, props.selector, {
|
|
246
|
+
compare: shallow,
|
|
247
247
|
})
|
|
248
248
|
|
|
249
249
|
return typeof props.children === 'function'
|
|
@@ -257,7 +257,9 @@ export function useAsyncThrottler<TFn extends AnyAsyncFunction, TSelected = {}>(
|
|
|
257
257
|
asyncThrottler.fn = fn
|
|
258
258
|
asyncThrottler.setOptions(mergedOptions)
|
|
259
259
|
|
|
260
|
-
const state =
|
|
260
|
+
const state = useSelector(asyncThrottler.store, selector, {
|
|
261
|
+
compare: shallow,
|
|
262
|
+
})
|
|
261
263
|
|
|
262
264
|
/* eslint-disable react-hooks/exhaustive-deps -- cleanup only; runs on unmount */
|
|
263
265
|
useEffect(() => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useEffect, useMemo, useState } from 'preact/hooks'
|
|
2
2
|
import { Batcher } from '@tanstack/pacer/batcher'
|
|
3
|
-
import { shallow,
|
|
3
|
+
import { shallow, useSelector } from '@tanstack/preact-store'
|
|
4
4
|
import { useDefaultPacerOptions } from '../provider/PacerProvider'
|
|
5
5
|
import type { Store } from '@tanstack/preact-store'
|
|
6
6
|
import type { BatcherOptions, BatcherState } from '@tanstack/pacer/batcher'
|
|
@@ -46,8 +46,8 @@ export interface PreactBatcher<TValue, TSelected = {}> extends Omit<
|
|
|
46
46
|
readonly state: Readonly<TSelected>
|
|
47
47
|
/**
|
|
48
48
|
* @deprecated Use `batcher.state` instead of `batcher.store.state` if you want to read reactive state.
|
|
49
|
-
* The state on the store object is not reactive, as it has not been wrapped in a `
|
|
50
|
-
* Although, you can make the state reactive by using the `
|
|
49
|
+
* The state on the store object is not reactive, as it has not been wrapped in a `useSelector` hook internally.
|
|
50
|
+
* Although, you can make the state reactive by using the `useSelector` in your own usage.
|
|
51
51
|
*/
|
|
52
52
|
readonly store: Store<Readonly<BatcherState<TValue>>>
|
|
53
53
|
}
|
|
@@ -201,8 +201,8 @@ export function useBatcher<TValue, TSelected = {}>(
|
|
|
201
201
|
selector: (state: BatcherState<TValue>) => TSelected
|
|
202
202
|
children: ((state: TSelected) => ComponentChildren) | ComponentChildren
|
|
203
203
|
}) {
|
|
204
|
-
const selected =
|
|
205
|
-
|
|
204
|
+
const selected = useSelector(batcherInstance.store, props.selector, {
|
|
205
|
+
compare: shallow,
|
|
206
206
|
})
|
|
207
207
|
|
|
208
208
|
return typeof props.children === 'function'
|
|
@@ -228,7 +228,7 @@ export function useBatcher<TValue, TSelected = {}>(
|
|
|
228
228
|
}, [])
|
|
229
229
|
/* eslint-enable react-hooks/exhaustive-deps */
|
|
230
230
|
|
|
231
|
-
const state =
|
|
231
|
+
const state = useSelector(batcher.store, selector, { compare: shallow })
|
|
232
232
|
|
|
233
233
|
return useMemo(
|
|
234
234
|
() =>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useEffect, useMemo, useState } from 'preact/hooks'
|
|
2
2
|
import { Debouncer } from '@tanstack/pacer/debouncer'
|
|
3
|
-
import { shallow,
|
|
3
|
+
import { shallow, useSelector } from '@tanstack/preact-store'
|
|
4
4
|
import { useDefaultPacerOptions } from '../provider/PacerProvider'
|
|
5
5
|
import type { Store } from '@tanstack/preact-store'
|
|
6
6
|
import type {
|
|
@@ -50,8 +50,8 @@ export interface PreactDebouncer<
|
|
|
50
50
|
readonly state: Readonly<TSelected>
|
|
51
51
|
/**
|
|
52
52
|
* @deprecated Use `debouncer.state` instead of `debouncer.store.state` if you want to read reactive state.
|
|
53
|
-
* The state on the store object is not reactive, as it has not been wrapped in a `
|
|
54
|
-
* Although, you can make the state reactive by using the `
|
|
53
|
+
* The state on the store object is not reactive, as it has not been wrapped in a `useSelector` hook internally.
|
|
54
|
+
* Although, you can make the state reactive by using the `useSelector` in your own usage.
|
|
55
55
|
*/
|
|
56
56
|
readonly store: Store<Readonly<DebouncerState<TFn>>>
|
|
57
57
|
}
|
|
@@ -179,8 +179,8 @@ export function useDebouncer<TFn extends AnyFunction, TSelected = {}>(
|
|
|
179
179
|
selector: (state: DebouncerState<TFn>) => TSelected
|
|
180
180
|
children: ((state: TSelected) => ComponentChildren) | ComponentChildren
|
|
181
181
|
}) {
|
|
182
|
-
const selected =
|
|
183
|
-
|
|
182
|
+
const selected = useSelector(debouncerInstance.store, props.selector, {
|
|
183
|
+
compare: shallow,
|
|
184
184
|
})
|
|
185
185
|
|
|
186
186
|
return typeof props.children === 'function'
|
|
@@ -206,7 +206,7 @@ export function useDebouncer<TFn extends AnyFunction, TSelected = {}>(
|
|
|
206
206
|
}, [])
|
|
207
207
|
/* eslint-enable react-hooks/exhaustive-deps */
|
|
208
208
|
|
|
209
|
-
const state =
|
|
209
|
+
const state = useSelector(debouncer.store, selector, { compare: shallow })
|
|
210
210
|
|
|
211
211
|
return useMemo(
|
|
212
212
|
() =>
|
package/src/queuer/useQueuer.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useEffect, useMemo, useState } from 'preact/hooks'
|
|
2
2
|
import { Queuer } from '@tanstack/pacer/queuer'
|
|
3
|
-
import { shallow,
|
|
3
|
+
import { shallow, useSelector } from '@tanstack/preact-store'
|
|
4
4
|
import { useDefaultPacerOptions } from '../provider/PacerProvider'
|
|
5
5
|
import type { Store } from '@tanstack/preact-store'
|
|
6
6
|
import type { QueuerOptions, QueuerState } from '@tanstack/pacer/queuer'
|
|
@@ -46,8 +46,8 @@ export interface PreactQueuer<TValue, TSelected = {}> extends Omit<
|
|
|
46
46
|
readonly state: Readonly<TSelected>
|
|
47
47
|
/**
|
|
48
48
|
* @deprecated Use `queuer.state` instead of `queuer.store.state` if you want to read reactive state.
|
|
49
|
-
* The state on the store object is not reactive, as it has not been wrapped in a `
|
|
50
|
-
* Although, you can make the state reactive by using the `
|
|
49
|
+
* The state on the store object is not reactive, as it has not been wrapped in a `useSelector` hook internally.
|
|
50
|
+
* Although, you can make the state reactive by using the `useSelector` in your own usage.
|
|
51
51
|
*/
|
|
52
52
|
readonly store: Store<Readonly<QueuerState<TValue>>>
|
|
53
53
|
}
|
|
@@ -211,8 +211,8 @@ export function useQueuer<TValue, TSelected = {}>(
|
|
|
211
211
|
selector: (state: QueuerState<TValue>) => TSelected
|
|
212
212
|
children: ((state: TSelected) => ComponentChildren) | ComponentChildren
|
|
213
213
|
}) {
|
|
214
|
-
const selected =
|
|
215
|
-
|
|
214
|
+
const selected = useSelector(queuerInstance.store, props.selector, {
|
|
215
|
+
compare: shallow,
|
|
216
216
|
})
|
|
217
217
|
|
|
218
218
|
return typeof props.children === 'function'
|
|
@@ -238,7 +238,7 @@ export function useQueuer<TValue, TSelected = {}>(
|
|
|
238
238
|
}, [])
|
|
239
239
|
/* eslint-enable react-hooks/exhaustive-deps */
|
|
240
240
|
|
|
241
|
-
const state =
|
|
241
|
+
const state = useSelector(queuer.store, selector, { compare: shallow })
|
|
242
242
|
|
|
243
243
|
return useMemo(
|
|
244
244
|
() =>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useEffect, useMemo, useState } from 'preact/hooks'
|
|
2
2
|
import { RateLimiter } from '@tanstack/pacer/rate-limiter'
|
|
3
|
-
import { shallow,
|
|
3
|
+
import { shallow, useSelector } from '@tanstack/preact-store'
|
|
4
4
|
import { useDefaultPacerOptions } from '../provider/PacerProvider'
|
|
5
5
|
import type { Store } from '@tanstack/preact-store'
|
|
6
6
|
import type {
|
|
@@ -50,8 +50,8 @@ export interface PreactRateLimiter<
|
|
|
50
50
|
readonly state: Readonly<TSelected>
|
|
51
51
|
/**
|
|
52
52
|
* @deprecated Use `rateLimiter.state` instead of `rateLimiter.store.state` if you want to read reactive state.
|
|
53
|
-
* The state on the store object is not reactive, as it has not been wrapped in a `
|
|
54
|
-
* Although, you can make the state reactive by using the `
|
|
53
|
+
* The state on the store object is not reactive, as it has not been wrapped in a `useSelector` hook internally.
|
|
54
|
+
* Although, you can make the state reactive by using the `useSelector` in your own usage.
|
|
55
55
|
*/
|
|
56
56
|
readonly store: Store<Readonly<RateLimiterState>>
|
|
57
57
|
}
|
|
@@ -206,8 +206,8 @@ export function useRateLimiter<TFn extends AnyFunction, TSelected = {}>(
|
|
|
206
206
|
selector: (state: RateLimiterState) => TSelected
|
|
207
207
|
children: ((state: TSelected) => ComponentChildren) | ComponentChildren
|
|
208
208
|
}) {
|
|
209
|
-
const selected =
|
|
210
|
-
|
|
209
|
+
const selected = useSelector(rateLimiterInstance.store, props.selector, {
|
|
210
|
+
compare: shallow,
|
|
211
211
|
})
|
|
212
212
|
|
|
213
213
|
return typeof props.children === 'function'
|
|
@@ -231,7 +231,7 @@ export function useRateLimiter<TFn extends AnyFunction, TSelected = {}>(
|
|
|
231
231
|
}, [])
|
|
232
232
|
/* eslint-enable react-hooks/exhaustive-deps */
|
|
233
233
|
|
|
234
|
-
const state =
|
|
234
|
+
const state = useSelector(rateLimiter.store, selector, { compare: shallow })
|
|
235
235
|
|
|
236
236
|
return useMemo(
|
|
237
237
|
() =>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useEffect, useMemo, useState } from 'preact/hooks'
|
|
2
2
|
import { Throttler } from '@tanstack/pacer/throttler'
|
|
3
|
-
import { shallow,
|
|
3
|
+
import { shallow, useSelector } from '@tanstack/preact-store'
|
|
4
4
|
import { useDefaultPacerOptions } from '../provider/PacerProvider'
|
|
5
5
|
import type { Store } from '@tanstack/preact-store'
|
|
6
6
|
import type { AnyFunction } from '@tanstack/pacer/types'
|
|
@@ -50,8 +50,8 @@ export interface PreactThrottler<
|
|
|
50
50
|
readonly state: Readonly<TSelected>
|
|
51
51
|
/**
|
|
52
52
|
* @deprecated Use `throttler.state` instead of `throttler.store.state` if you want to read reactive state.
|
|
53
|
-
* The state on the store object is not reactive, as it has not been wrapped in a `
|
|
54
|
-
* Although, you can make the state reactive by using the `
|
|
53
|
+
* The state on the store object is not reactive, as it has not been wrapped in a `useSelector` hook internally.
|
|
54
|
+
* Although, you can make the state reactive by using the `useSelector` in your own usage.
|
|
55
55
|
*/
|
|
56
56
|
readonly store: Store<Readonly<ThrottlerState<TFn>>>
|
|
57
57
|
}
|
|
@@ -184,8 +184,8 @@ export function useThrottler<TFn extends AnyFunction, TSelected = {}>(
|
|
|
184
184
|
selector: (state: ThrottlerState<TFn>) => TSelected
|
|
185
185
|
children: ((state: TSelected) => ComponentChildren) | ComponentChildren
|
|
186
186
|
}) {
|
|
187
|
-
const selected =
|
|
188
|
-
|
|
187
|
+
const selected = useSelector(throttlerInstance.store, props.selector, {
|
|
188
|
+
compare: shallow,
|
|
189
189
|
})
|
|
190
190
|
|
|
191
191
|
return typeof props.children === 'function'
|
|
@@ -199,7 +199,7 @@ export function useThrottler<TFn extends AnyFunction, TSelected = {}>(
|
|
|
199
199
|
throttler.fn = fn
|
|
200
200
|
throttler.setOptions(mergedOptions)
|
|
201
201
|
|
|
202
|
-
const state =
|
|
202
|
+
const state = useSelector(throttler.store, selector, { compare: shallow })
|
|
203
203
|
|
|
204
204
|
/* eslint-disable react-hooks/exhaustive-deps -- cleanup only; runs on unmount */
|
|
205
205
|
useEffect(() => {
|