react-bindings
Advanced tools
Comparing version 1.3.0 to 1.3.1
@@ -7,3 +7,3 @@ import type { BindingDependencies, BindingsArrayDependencies, NamedBindingDependencies } from './binding-dependencies'; | ||
/** Extracts the values of either a single binding, bindings in an array or tuple, or a record with binding values */ | ||
export declare type ExtractBindingValueTypes<DependenciesT extends BindingDependencies> = DependenciesT extends ReadonlyBinding ? InferBindingGetType<DependenciesT> : DependenciesT extends NamedBindingDependencies ? ExtractNamedBindingsValues<DependenciesT> : DependenciesT extends BindingsArrayDependencies ? ExtractBindingsArrayValues<DependenciesT> : void; | ||
export declare type ExtractBindingValueTypes<DependenciesT extends BindingDependencies> = DependenciesT extends ReadonlyBinding ? InferBindingGetType<DependenciesT> : DependenciesT extends NamedBindingDependencies ? ExtractNamedBindingsValues<DependenciesT> : DependenciesT extends BindingsArrayDependencies ? ExtractBindingsArrayValues<DependenciesT> : Record<string, never>; | ||
//# sourceMappingURL=extract-binding-value-types.d.ts.map |
@@ -5,2 +5,3 @@ "use strict"; | ||
const type_utils_1 = require("../binding-utils/type-utils"); | ||
const emptyValues = Object.freeze({}); | ||
const extractBindingDependencyValues = ({ bindings, namedBindingsKeys }) => { | ||
@@ -31,3 +32,3 @@ var _a; | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return | ||
return undefined; | ||
return emptyValues; | ||
} | ||
@@ -34,0 +35,0 @@ }; |
@@ -15,3 +15,3 @@ import type { BindingDependencies } from '../../binding/types/binding-dependencies'; | ||
/** A derived binding is a binding derived from zero or more other bindings */ | ||
export declare const useDerivedBinding: <GetT, DependenciesT extends BindingDependencies = Record<string, never>>(bindings: DependenciesT, transformer: UseDerivedBindingTransformer<GetT, DependenciesT>, { id, deps, areInputValuesEqual, detectInputChanges, makeComparableInputValue, areOutputValuesEqual, detectOutputChanges, limitMode, limitMSec, limitType, priority, queue }: DerivedBindingOptions<GetT>) => ReadonlyBinding<GetT>; | ||
export declare const useDerivedBinding: <GetT, DependenciesT extends BindingDependencies = Record<string, never>>(bindings: DependenciesT | undefined, transformer: UseDerivedBindingTransformer<GetT, DependenciesT>, { id, deps, areInputValuesEqual, detectInputChanges, makeComparableInputValue, areOutputValuesEqual, detectOutputChanges, limitMode, limitMSec, limitType, priority, queue }: DerivedBindingOptions<GetT>) => ReadonlyBinding<GetT>; | ||
//# sourceMappingURL=use-derived-binding.d.ts.map |
@@ -11,2 +11,3 @@ "use strict"; | ||
const use_binding_effect_1 = require("../../use-binding-effect/use-binding-effect"); | ||
const emptyDependencies = Object.freeze({}); | ||
/** A derived binding is a binding derived from zero or more other bindings */ | ||
@@ -25,3 +26,3 @@ const useDerivedBinding = (bindings, transformer, { id, deps, areInputValuesEqual, detectInputChanges = true, makeComparableInputValue, areOutputValuesEqual, detectOutputChanges = true, limitMode, limitMSec, limitType, priority, queue }) => { | ||
try { | ||
return transformer(dependencyValues, bindings); | ||
return transformer(dependencyValues, bindings !== null && bindings !== void 0 ? bindings : emptyDependencies); | ||
} | ||
@@ -28,0 +29,0 @@ finally { |
@@ -15,3 +15,3 @@ import type { BindingDependencies } from '../binding/types/binding-dependencies'; | ||
/** Use when a binding contains another binding, to listen to the second-level binding if either the first or second levels change */ | ||
export declare const useFlattenedBinding: <GetT, DependenciesT extends BindingDependencies = Record<string, never>>(bindings: DependenciesT, transformer: UseFlattenedBindingTransformer<GetT, DependenciesT>, { id, deps, areInputValuesEqual, detectInputChanges, makeComparableInputValue, areOutputValuesEqual, detectOutputChanges, limitMode, limitMSec, limitType, priority, queue }: DerivedBindingOptions<GetT>) => ReadonlyBinding<GetT>; | ||
export declare const useFlattenedBinding: <GetT, DependenciesT extends BindingDependencies = Record<string, never>>(bindings: DependenciesT | undefined, transformer: UseFlattenedBindingTransformer<GetT, DependenciesT>, { id, deps, areInputValuesEqual, detectInputChanges, makeComparableInputValue, areOutputValuesEqual, detectOutputChanges, limitMode, limitMSec, limitType, priority, queue }: DerivedBindingOptions<GetT>) => ReadonlyBinding<GetT>; | ||
//# sourceMappingURL=flattened-binding.d.ts.map |
@@ -12,2 +12,3 @@ "use strict"; | ||
const use_binding_effect_1 = require("../use-binding-effect/use-binding-effect"); | ||
const emptyDependencies = Object.freeze({}); | ||
/** Use when a binding contains another binding, to listen to the second-level binding if either the first or second levels change */ | ||
@@ -25,3 +26,3 @@ const useFlattenedBinding = (bindings, transformer, { id, deps = [], areInputValuesEqual, detectInputChanges = true, makeComparableInputValue, areOutputValuesEqual, detectOutputChanges = true, | ||
const getDependencyValues = () => (0, extract_binding_dependency_values_1.extractBindingDependencyValues)({ bindings, namedBindingsKeys }); | ||
const internalBinding = (0, use_binding_1.useBinding)(() => transformer(getDependencyValues(), bindings).get(), { | ||
const internalBinding = (0, use_binding_1.useBinding)(() => transformer(getDependencyValues(), bindings !== null && bindings !== void 0 ? bindings : emptyDependencies).get(), { | ||
id, | ||
@@ -36,3 +37,3 @@ areEqual: areOutputValuesEqual, | ||
secondLevelBindingListenerRemover.current = undefined; | ||
const secondLevelBinding = transformer(dependencyValues, bindings); | ||
const secondLevelBinding = transformer(dependencyValues, bindings !== null && bindings !== void 0 ? bindings : emptyDependencies); | ||
internalBinding.set(secondLevelBinding.get()); | ||
@@ -49,3 +50,3 @@ if (isMounted.current) { | ||
(0, react_1.useEffect)(() => { | ||
const secondLevelBinding = transformer(getDependencyValues(), bindings); | ||
const secondLevelBinding = transformer(getDependencyValues(), bindings !== null && bindings !== void 0 ? bindings : emptyDependencies); | ||
secondLevelBindingListenerRemover.current = secondLevelBinding.addChangeListener(() => { | ||
@@ -52,0 +53,0 @@ internalBinding.set(secondLevelBinding.get()); |
@@ -20,3 +20,3 @@ import type { BindingDependencies } from '../binding/types/binding-dependencies'; | ||
*/ | ||
export declare const useBindingEffect: <DependenciesT extends BindingDependencies = Record<string, never>>(bindings: DependenciesT, callback: UseBindingEffectCallback<DependenciesT>, { id, deps, areInputValuesEqual, detectInputChanges, makeComparableInputValue, triggerOnMount, limitMode, limitMSec, limitType, priority, queue }?: UseBindingEffectOptions) => (() => void); | ||
export declare const useBindingEffect: <DependenciesT extends BindingDependencies = Record<string, never>>(bindings: DependenciesT | undefined, callback: UseBindingEffectCallback<DependenciesT>, { id, deps, areInputValuesEqual, detectInputChanges, makeComparableInputValue, triggerOnMount, limitMode, limitMSec, limitType, priority, queue }?: UseBindingEffectOptions) => (() => void); | ||
//# sourceMappingURL=use-binding-effect.d.ts.map |
@@ -13,3 +13,3 @@ "use strict"; | ||
const use_limiter_1 = require("../limiter/use-limiter"); | ||
const emptyNamedBindings = Object.freeze({}); | ||
const emptyDependencies = Object.freeze({}); | ||
/** | ||
@@ -31,3 +31,3 @@ * Calls the specified callback function any time any of the specified bindings are changed. | ||
const namedBindingsKeys = namedBindings !== undefined ? (0, get_typed_keys_1.getTypedKeys)(namedBindings) : undefined; | ||
const stableAllBindings = (0, use_stable_value_1.useStableValue)(isNonNamedBindings ? (0, array_like_1.normalizeAsArray)(nonNamedBindings) : Object.values(namedBindings !== null && namedBindings !== void 0 ? namedBindings : emptyNamedBindings)); | ||
const stableAllBindings = (0, use_stable_value_1.useStableValue)(isNonNamedBindings ? (0, array_like_1.normalizeAsArray)(nonNamedBindings) : Object.values(namedBindings !== null && namedBindings !== void 0 ? namedBindings : emptyDependencies)); | ||
// Doesn't need to be stable since always used in a callback ref | ||
@@ -70,3 +70,3 @@ // eslint-disable-next-line @typescript-eslint/no-unsafe-return | ||
} | ||
callback(getDependencyValues(), bindings); | ||
callback(getDependencyValues(), bindings !== null && bindings !== void 0 ? bindings : emptyDependencies); | ||
}); | ||
@@ -73,0 +73,0 @@ const performChecksAndTriggerCallbackIfNeeded = (0, use_callback_ref_1.useCallbackRef)(() => { |
{ | ||
"name": "react-bindings", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"description": "Data bindings for React", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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
198149
2356