react-waitables
Advanced tools
Comparing version 1.9.1 to 1.9.2
@@ -17,4 +17,5 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__exportStar(require("./pick-waitables-consumer-named-transformers"), exports); | ||
__exportStar(require("./types/exports"), exports); | ||
__exportStar(require("./WaitablesConsumer"), exports); | ||
//# sourceMappingURL=exports.js.map |
@@ -12,2 +12,3 @@ "use strict"; | ||
const use_derived_waitable_1 = require("../../specialized-waitables/use-derived-waitable/use-derived-waitable"); | ||
const pick_waitables_consumer_named_transformers_1 = require("./pick-waitables-consumer-named-transformers"); | ||
/** | ||
@@ -41,15 +42,6 @@ * A component that is rerendered based on input waitable and binding changes. | ||
*/ | ||
const WaitablesConsumer = ({ children, id = 'waitable-consumer', dependencies, | ||
// WaitablesConsumerNamedTransformers | ||
always, ifError, ifErrorOrLoading, ifLoaded, ifLoading, | ||
// LimiterOptions | ||
limitMSec, limitMode, limitType, priority, queue }) => { | ||
const limiterOptions = { limitMSec, limitMode, limitType, priority, queue }; | ||
const propsBasedTransformers = { | ||
always, | ||
ifError, | ||
ifErrorOrLoading, | ||
ifLoaded, | ||
ifLoading | ||
}; | ||
const WaitablesConsumer = (props) => { | ||
const { children, id = 'waitable-consumer', dependencies } = props; | ||
const limiterOptions = (0, react_bindings_1.pickLimiterOptions)(props); | ||
const propsBasedTransformers = (0, pick_waitables_consumer_named_transformers_1.pickWaitablesConsumerNamedTransformers)(props); | ||
const ifErrorTransformer = (0, react_bindings_1.useCallbackRef)(() => { var _a, _b; return (_b = (_a = (0, waitable_consumer_if_error_transformer_1.getDefaultWaitablesConsumerIfErrorTransformer)()) === null || _a === void 0 ? void 0 : _a(dependencies, node)) !== null && _b !== void 0 ? _b : null; }); | ||
@@ -59,4 +51,4 @@ const combinedTransformers = [...(0, array_like_1.normalizeAsArray)(children), propsBasedTransformers, { ifError: ifErrorTransformer }]; | ||
id, | ||
priority, | ||
queue, | ||
priority: limiterOptions.priority, | ||
queue: limiterOptions.queue, | ||
detectErrorChanges: false, | ||
@@ -63,0 +55,0 @@ detectValueChanges: false |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.useWaitable = void 0; | ||
const client_run_queue_1 = require("client-run-queue"); | ||
const react_1 = require("react"); | ||
@@ -35,8 +34,7 @@ const react_bindings_1 = require("react-bindings"); | ||
*/ | ||
const useWaitable = (primaryFunc, { id, deps, addFields, areErrorsEqual = react_bindings_1.areEqual, detectErrorChanges = true, areValuesEqual = react_bindings_1.areEqual, detectValueChanges = true, lockedUntil: lockedUntilBindings, lockedWhile: lockedWhileBindings, hardResetBindings, softResetBindings, defaultValue, onFailure, onReset, onSuccess, limitMSec, limitMode, limitType, priority = client_run_queue_1.DEFAULT_PRIORITY, queue }) => { | ||
const useWaitable = (primaryFunc, args) => { | ||
var _a; | ||
const limiterOptions = { limitMSec, limitMode, limitType, priority, queue }; | ||
const defaultQueue = (0, react_bindings_1.useDefaultQueue)(); | ||
const { id, deps, addFields, areErrorsEqual = react_bindings_1.areEqual, detectErrorChanges = true, areValuesEqual = react_bindings_1.areEqual, detectValueChanges = true, lockedUntil: lockedUntilBindings, lockedWhile: lockedWhileBindings, hardResetBindings, softResetBindings, defaultValue, onFailure, onReset, onSuccess } = args; | ||
const limiterOptions = (0, react_bindings_1.pickLimiterOptions)(args); | ||
const isMounted = (0, use_is_mounted_ref_1.useIsMountedRef)(); | ||
queue = queue !== null && queue !== void 0 ? queue : defaultQueue; | ||
/** The success value store */ | ||
@@ -43,0 +41,0 @@ const value = (0, react_bindings_1.useBinding)(() => undefined, { |
@@ -0,3 +1,4 @@ | ||
export * from './pick-waitables-consumer-named-transformers'; | ||
export * from './types/exports'; | ||
export * from './WaitablesConsumer'; | ||
//# sourceMappingURL=exports.d.ts.map |
@@ -34,3 +34,3 @@ import React from 'react'; | ||
*/ | ||
export declare const WaitablesConsumer: <DependenciesT extends WaitableDependencies>({ children, id, dependencies, always, ifError, ifErrorOrLoading, ifLoaded, ifLoading, limitMSec, limitMode, limitType, priority, queue }: import("react-bindings").LimiterOptions & WaitablesConsumerNamedTransformers<DependenciesT> & { | ||
export declare const WaitablesConsumer: <DependenciesT extends WaitableDependencies>(props: import("react-bindings").LimiterOptions & WaitablesConsumerNamedTransformers<DependenciesT> & { | ||
id?: string | undefined; | ||
@@ -37,0 +37,0 @@ dependencies?: DependenciesT | undefined; |
@@ -0,3 +1,4 @@ | ||
export * from './pick-waitables-consumer-named-transformers'; | ||
export * from './types/exports'; | ||
export * from './WaitablesConsumer'; | ||
//# sourceMappingURL=exports.js.map |
import React from 'react'; | ||
import { BindingsConsumer, useCallbackRef } from 'react-bindings'; | ||
import { BindingsConsumer, pickLimiterOptions, useCallbackRef } from 'react-bindings'; | ||
import { getDefaultWaitablesConsumerIfErrorTransformer } from '../../config/waitable-consumer-if-error-transformer'; | ||
import { normalizeAsArray } from '../../internal-utils/array-like'; | ||
import { useDerivedWaitable } from '../../specialized-waitables/use-derived-waitable/use-derived-waitable'; | ||
import { pickWaitablesConsumerNamedTransformers } from './pick-waitables-consumer-named-transformers'; | ||
/** | ||
@@ -34,15 +35,6 @@ * A component that is rerendered based on input waitable and binding changes. | ||
*/ | ||
export const WaitablesConsumer = ({ children, id = 'waitable-consumer', dependencies, | ||
// WaitablesConsumerNamedTransformers | ||
always, ifError, ifErrorOrLoading, ifLoaded, ifLoading, | ||
// LimiterOptions | ||
limitMSec, limitMode, limitType, priority, queue }) => { | ||
const limiterOptions = { limitMSec, limitMode, limitType, priority, queue }; | ||
const propsBasedTransformers = { | ||
always, | ||
ifError, | ||
ifErrorOrLoading, | ||
ifLoaded, | ||
ifLoading | ||
}; | ||
export const WaitablesConsumer = (props) => { | ||
const { children, id = 'waitable-consumer', dependencies } = props; | ||
const limiterOptions = pickLimiterOptions(props); | ||
const propsBasedTransformers = pickWaitablesConsumerNamedTransformers(props); | ||
const ifErrorTransformer = useCallbackRef(() => { var _a, _b; return (_b = (_a = getDefaultWaitablesConsumerIfErrorTransformer()) === null || _a === void 0 ? void 0 : _a(dependencies, node)) !== null && _b !== void 0 ? _b : null; }); | ||
@@ -52,4 +44,4 @@ const combinedTransformers = [...normalizeAsArray(children), propsBasedTransformers, { ifError: ifErrorTransformer }]; | ||
id, | ||
priority, | ||
queue, | ||
priority: limiterOptions.priority, | ||
queue: limiterOptions.queue, | ||
detectErrorChanges: false, | ||
@@ -56,0 +48,0 @@ detectValueChanges: false |
@@ -1,4 +0,3 @@ | ||
import { DEFAULT_PRIORITY } from 'client-run-queue'; | ||
import { useMemo, useRef } from 'react'; | ||
import { areEqual, useBinding, useBindingEffect, useCallbackRef, useDefaultQueue, useDerivedBinding, useLimiter, useTransientDerivedBinding } from 'react-bindings'; | ||
import { areEqual, pickLimiterOptions, useBinding, useBindingEffect, useCallbackRef, useDerivedBinding, useLimiter, useTransientDerivedBinding } from 'react-bindings'; | ||
import { isSpecialLoggingEnabledFor } from '../config/logging'; | ||
@@ -32,8 +31,7 @@ import { useIsMountedRef } from '../internal-hooks/use-is-mounted-ref'; | ||
*/ | ||
export const useWaitable = (primaryFunc, { id, deps, addFields, areErrorsEqual = areEqual, detectErrorChanges = true, areValuesEqual = areEqual, detectValueChanges = true, lockedUntil: lockedUntilBindings, lockedWhile: lockedWhileBindings, hardResetBindings, softResetBindings, defaultValue, onFailure, onReset, onSuccess, limitMSec, limitMode, limitType, priority = DEFAULT_PRIORITY, queue }) => { | ||
export const useWaitable = (primaryFunc, args) => { | ||
var _a; | ||
const limiterOptions = { limitMSec, limitMode, limitType, priority, queue }; | ||
const defaultQueue = useDefaultQueue(); | ||
const { id, deps, addFields, areErrorsEqual = areEqual, detectErrorChanges = true, areValuesEqual = areEqual, detectValueChanges = true, lockedUntil: lockedUntilBindings, lockedWhile: lockedWhileBindings, hardResetBindings, softResetBindings, defaultValue, onFailure, onReset, onSuccess } = args; | ||
const limiterOptions = pickLimiterOptions(args); | ||
const isMounted = useIsMountedRef(); | ||
queue = queue !== null && queue !== void 0 ? queue : defaultQueue; | ||
/** The success value store */ | ||
@@ -40,0 +38,0 @@ const value = useBinding(() => undefined, { |
@@ -21,3 +21,3 @@ import type { EmptyObject } from 'react-bindings'; | ||
*/ | ||
export declare const useWaitable: <SuccessT, FailureT = any, ExtraFieldsT extends object = EmptyObject>(primaryFunc: WaitablePrimaryFunction<SuccessT, FailureT>, { id, deps, addFields, areErrorsEqual, detectErrorChanges, areValuesEqual, detectValueChanges, lockedUntil: lockedUntilBindings, lockedWhile: lockedWhileBindings, hardResetBindings, softResetBindings, defaultValue, onFailure, onReset, onSuccess, limitMSec, limitMode, limitType, priority, queue }: UseWaitableArgs<SuccessT, FailureT, ExtraFieldsT>) => Waitable<SuccessT, FailureT> & ExtraFieldsT; | ||
export declare const useWaitable: <SuccessT, FailureT = any, ExtraFieldsT extends object = EmptyObject>(primaryFunc: WaitablePrimaryFunction<SuccessT, FailureT>, args: UseWaitableArgs<SuccessT, FailureT, ExtraFieldsT>) => Waitable<SuccessT, FailureT> & ExtraFieldsT; | ||
//# sourceMappingURL=use-waitable.d.ts.map |
{ | ||
"name": "react-waitables", | ||
"version": "1.9.1", | ||
"version": "1.9.2", | ||
"description": "Async data bindings for React", | ||
@@ -41,3 +41,3 @@ "keywords": [ | ||
"is-promise": "^4.0.0", | ||
"react-bindings": "^1.14.1" | ||
"react-bindings": "^1.15.0" | ||
}, | ||
@@ -44,0 +44,0 @@ "devDependencies": { |
@@ -0,2 +1,3 @@ | ||
export * from './pick-waitables-consumer-named-transformers'; | ||
export * from './types/exports'; | ||
export * from './WaitablesConsumer'; |
@@ -1,2 +0,1 @@ | ||
import { DEFAULT_PRIORITY } from 'client-run-queue'; | ||
import { useMemo, useRef } from 'react'; | ||
@@ -6,6 +5,6 @@ import type { EmptyObject, ReadonlyBinding } from 'react-bindings'; | ||
areEqual, | ||
pickLimiterOptions, | ||
useBinding, | ||
useBindingEffect, | ||
useCallbackRef, | ||
useDefaultQueue, | ||
useDerivedBinding, | ||
@@ -52,3 +51,5 @@ useLimiter, | ||
primaryFunc: WaitablePrimaryFunction<SuccessT, FailureT>, | ||
{ | ||
args: UseWaitableArgs<SuccessT, FailureT, ExtraFieldsT> | ||
): Waitable<SuccessT, FailureT> & ExtraFieldsT => { | ||
const { | ||
id, | ||
@@ -68,17 +69,9 @@ deps, | ||
onReset, | ||
onSuccess, | ||
limitMSec, | ||
limitMode, | ||
limitType, | ||
priority = DEFAULT_PRIORITY, | ||
queue | ||
}: UseWaitableArgs<SuccessT, FailureT, ExtraFieldsT> | ||
): Waitable<SuccessT, FailureT> & ExtraFieldsT => { | ||
const limiterOptions = { limitMSec, limitMode, limitType, priority, queue }; | ||
onSuccess | ||
} = args; | ||
const defaultQueue = useDefaultQueue(); | ||
const limiterOptions = pickLimiterOptions(args); | ||
const isMounted = useIsMountedRef(); | ||
queue = queue ?? defaultQueue; | ||
/** The success value store */ | ||
@@ -85,0 +78,0 @@ const value = useBinding<SuccessT | undefined>(() => undefined, { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
463322
469
7213
+ Addedclient-run-queue@2.3.8(transitive)
+ Addeddoublell@1.1.3(transitive)
- Removedclient-run-queue@2.3.7(transitive)
- Removeddoublell@1.1.2(transitive)
Updatedreact-bindings@^1.15.0