Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-waitables

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-waitables - npm Package Compare versions

Comparing version 1.6.1 to 1.6.2

3

lib/components/WaitablesConsumer/WaitablesConsumer.js

@@ -10,3 +10,2 @@ "use strict";

const waitable_consumer_if_error_transformer_1 = require("../../config/waitable-consumer-if-error-transformer");
const use_callback_ref_1 = require("../../internal-hooks/use-callback-ref");
const array_like_1 = require("../../internal-utils/array-like");

@@ -55,3 +54,3 @@ const use_derived_waitable_1 = require("../../specialized-waitables/use-derived-waitable/use-derived-waitable");

};
const ifErrorTransformer = (0, use_callback_ref_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; });
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; });
const combinedTransformers = [...(0, array_like_1.normalizeAsArray)(children), propsBasedTransformers, { ifError: ifErrorTransformer }];

@@ -58,0 +57,0 @@ const node = (0, use_derived_waitable_1.useDerivedWaitable)(dependencies, combinedTransformers, {

@@ -6,4 +6,2 @@ "use strict";

const react_bindings_1 = require("react-bindings");
const use_callback_ref_1 = require("../../internal-hooks/use-callback-ref");
const use_stable_value_1 = require("../../internal-hooks/use-stable-value");
const array_like_1 = require("../../internal-utils/array-like");

@@ -54,3 +52,3 @@ const extract_waitable_dependency_values_1 = require("../../internal-utils/extract-waitable-dependency-values");

const namedDependencyKeys = namedDependencies !== undefined ? (0, get_typed_keys_1.getTypedKeys)(namedDependencies) : undefined;
const stableAllDependencies = (0, use_stable_value_1.useStableValue)(isNonNamedDependencies ? (0, array_like_1.normalizeAsArray)(nonNamedDependencies) : Object.values(namedDependencies !== null && namedDependencies !== void 0 ? namedDependencies : emptyDependencies));
const stableAllDependencies = (0, react_bindings_1.useStableValue)(isNonNamedDependencies ? (0, array_like_1.normalizeAsArray)(nonNamedDependencies) : Object.values(namedDependencies !== null && namedDependencies !== void 0 ? namedDependencies : emptyDependencies));
const stableAllWaitables = (0, react_1.useMemo)(() => stableAllDependencies.filter((dep) => (0, utils_1.isWaitable)(dep)), [stableAllDependencies]);

@@ -71,3 +69,3 @@ const stableAllBindings = (0, react_1.useMemo)(() => stableAllDependencies.filter((dep) => (0, react_bindings_1.isBinding)(dep)), [stableAllDependencies]);

*/
const getLoadedTransformer = (0, use_callback_ref_1.useCallbackRef)(() => {
const getLoadedTransformer = (0, react_bindings_1.useCallbackRef)(() => {
for (const transformer of normalizedTransformers) {

@@ -92,3 +90,3 @@ if (typeof transformer === 'function') {

*/
const getErrorTransformer = (0, use_callback_ref_1.useCallbackRef)(() => {
const getErrorTransformer = (0, react_bindings_1.useCallbackRef)(() => {
var _a, _b;

@@ -111,3 +109,3 @@ for (const transformer of normalizedTransformers) {

*/
const getLoadingTransformer = (0, use_callback_ref_1.useCallbackRef)(() => {
const getLoadingTransformer = (0, react_bindings_1.useCallbackRef)(() => {
var _a, _b;

@@ -131,3 +129,3 @@ for (const transformer of normalizedTransformers) {

*/
const evaluate = (0, use_callback_ref_1.useCallbackRef)(({ setSuccess, setFailure, wasReset }) => {
const evaluate = (0, react_bindings_1.useCallbackRef)(({ setSuccess, setFailure, wasReset }) => {
const { allWaitablesAreLoaded, anyWaitablesHadErrors, lastError, values } = (0, extract_waitable_dependency_values_1.extractOptionalWaitableDependencyValues)({

@@ -134,0 +132,0 @@ dependencies,

@@ -25,3 +25,2 @@ "use strict";

const react_bindings_1 = require("react-bindings");
const use_callback_ref_1 = require("../internal-hooks/use-callback-ref");
const use_derived_waitable_1 = require("../specialized-waitables/use-derived-waitable/use-derived-waitable");

@@ -45,3 +44,3 @@ /**

const isNotReady = (0, react_bindings_1.useDerivedBinding)(isReady, (isReady) => !isReady, { id: `${id}_isNotReady`, limitType: 'none' });
const output = (0, use_callback_ref_1.useCallbackRef)((...args) => __awaiter(void 0, void 0, void 0, function* () {
const output = (0, react_bindings_1.useCallbackRef)((...args) => __awaiter(void 0, void 0, void 0, function* () {
const waitResult = yield dependencyValues.wait(waitOptions);

@@ -48,0 +47,0 @@ const theDependencyValues = dependencyValues.value.get();

@@ -8,3 +8,2 @@ "use strict";

const logging_1 = require("../config/logging");
const use_callback_ref_1 = require("../internal-hooks/use-callback-ref");
const use_is_mounted_ref_1 = require("../internal-hooks/use-is-mounted-ref");

@@ -80,3 +79,3 @@ const array_like_1 = require("../internal-utils/array-like");

const limiter = (0, react_bindings_1.useLimiter)(Object.assign({ id, cancelOnUnmount: true }, limiterOptions));
const scheduleIfNeeded = (0, use_callback_ref_1.useCallbackRef)(() => limiter.limit(execPrimaryFuncIfNeeded));
const scheduleIfNeeded = (0, react_bindings_1.useCallbackRef)(() => limiter.limit(execPrimaryFuncIfNeeded));
/**

@@ -87,3 +86,3 @@ * Updates either using the primary function or the specified default value producer function.

*/
const updateWithDefaultValue = (0, use_callback_ref_1.useCallbackRef)(() => {
const updateWithDefaultValue = (0, react_bindings_1.useCallbackRef)(() => {
if (defaultValue === 'use-primary-function') {

@@ -105,3 +104,3 @@ return (0, update_waitable_bindings_with_primary_function_for_default_value_1.updateWaitableBindingsWithPrimaryFunctionForDefaultValue)({

});
const reset = (0, use_callback_ref_1.useCallbackRef)((resetType) => {
const reset = (0, react_bindings_1.useCallbackRef)((resetType) => {
alreadyRanFunc.current = false;

@@ -125,5 +124,5 @@ isBusy.set(false);

});
const hardReset = (0, use_callback_ref_1.useCallbackRef)(() => reset('hard'));
const softReset = (0, use_callback_ref_1.useCallbackRef)(() => reset('soft'));
const wait = (0, use_callback_ref_1.useCallbackRef)((options) => (0, wait_for_binding_values_1.waitForBindingValues)(Object.assign({ error, resetCount, value }, options)));
const hardReset = (0, react_bindings_1.useCallbackRef)(() => reset('hard'));
const softReset = (0, react_bindings_1.useCallbackRef)(() => reset('soft'));
const wait = (0, react_bindings_1.useCallbackRef)((options) => (0, wait_for_binding_values_1.waitForBindingValues)(Object.assign({ error, resetCount, value }, options)));
/** If true, this waitable is locked */

@@ -146,3 +145,3 @@ const isLocked = (0, react_bindings_1.useDerivedBinding)([...lockedUntil, ...lockedWhile], () => (0, are_any_bindings_falsey_1.areAnyBindingsFalsey)(lockedUntil) || (0, are_any_bindings_truthy_1.areAnyBindingsTruthy)(lockedWhile), { id: `${id}_locked`, limitType: 'none' });

*/
const execPrimaryFuncIfNeeded = (0, use_callback_ref_1.useCallbackRef)(() => {
const execPrimaryFuncIfNeeded = (0, react_bindings_1.useCallbackRef)(() => {
if (alreadyRanFunc.current || !isMounted.current) {

@@ -149,0 +148,0 @@ return;

{
"name": "react-waitables",
"version": "1.6.1",
"version": "1.6.2",
"description": "Async data bindings for React",

@@ -40,3 +40,3 @@ "keywords": [

"is-promise": "^4.0.0",
"react-bindings": "^1.7.1"
"react-bindings": "^1.9.0"
},

@@ -43,0 +43,0 @@ "devDependencies": {

import { useMemo } from 'react';
import { EmptyObject, isBinding, ReadonlyBinding, SingleOrArray } from 'react-bindings';
import { EmptyObject, isBinding, ReadonlyBinding, SingleOrArray, useCallbackRef, useStableValue } from 'react-bindings';
import { useCallbackRef } from '../../internal-hooks/use-callback-ref';
import { useStableValue } from '../../internal-hooks/use-stable-value';
import { concatArrays, normalizeAsArray, normalizeAsOptionalArray } from '../../internal-utils/array-like';

@@ -7,0 +5,0 @@ import { extractOptionalWaitableDependencyValues } from '../../internal-utils/extract-waitable-dependency-values';

@@ -1,4 +0,3 @@

import { useDerivedBinding } from 'react-bindings';
import { useCallbackRef, useDerivedBinding } from 'react-bindings';
import { useCallbackRef } from '../internal-hooks/use-callback-ref';
import { useDerivedWaitable } from '../specialized-waitables/use-derived-waitable/use-derived-waitable';

@@ -5,0 +4,0 @@ import type { InferRequiredWaitableAndBindingValueTypes } from '../waitable/types/infer-waitable-and-binding-value-types';

@@ -55,2 +55,23 @@ import { waitFor } from '@testing-library/react';

it('asynchronously set success value should be resolved with an asynchronous defaultValue function and then updated once the primary function completes', () =>
runInDom(({ onMount }) => {
const waitablePrimaryFunc: WaitablePrimaryFunction<number> = jest.fn(async ({ setSuccess }) => {
await sleep(50);
setSuccess(1);
});
const waitable = useWaitable<number>(waitablePrimaryFunc, {
id: 'test',
defaultValue: async () => -1
});
(async () => {
await waitFor(() => expect(waitable.value.get()).toBe(-1));
})();
onMount(async () => {
await waitFor(() => expect(waitable.value.get()).toBe(1));
expect(waitablePrimaryFunc).toHaveBeenCalledTimes(1);
});
}));
it('asynchronously set success value should be resolved after being given enough time to run', () =>

@@ -57,0 +78,0 @@ runInDom(({ onMount }) => {

@@ -9,2 +9,3 @@ import { DEFAULT_PRIORITY } from 'client-run-queue';

useBindingEffect,
useCallbackRef,
useDefaultQueue,

@@ -16,3 +17,2 @@ useDerivedBinding,

import { isSpecialLoggingEnabledFor } from '../config/logging';
import { useCallbackRef } from '../internal-hooks/use-callback-ref';
import { useIsMountedRef } from '../internal-hooks/use-is-mounted-ref';

@@ -19,0 +19,0 @@ import { normalizeAsArray } from '../internal-utils/array-like';

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc