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

@equinor/fusion-query

Package Overview
Dependencies
Maintainers
3
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@equinor/fusion-query - npm Package Compare versions

Comparing version 0.3.1 to 1.0.0

14

dist/esm/react/useDebounceQuery.js

@@ -1,17 +0,9 @@

import { useCallback, useMemo, useState } from 'react';
import { debounce, debounceTime, Subject, switchMap, tap } from 'rxjs';
import { useObservableState } from '@equinor/fusion-observable/react';
import { useState } from 'react';
import { useDebounce } from '@equinor/fusion-observable/react';
import Query from '../Query';
export const useDebounceQuery = (clientOrClientCtor, options) => {
const [client] = useState(() => clientOrClientCtor instanceof Query ? clientOrClientCtor : new Query(clientOrClientCtor));
const [querying, setQuerying] = useState(false);
const [queuer] = useState(() => { var _a; return (_a = options === null || options === void 0 ? void 0 : options.queuer) !== null && _a !== void 0 ? _a : new Subject(); });
const query = useCallback((args) => queuer.next(args), [queuer]);
const debounceFn = useMemo(() => typeof options.debounce === 'function'
? debounce(options.debounce)
: debounceTime(options.debounce), [options.debounce]);
const value = useObservableState(useMemo(() => queuer.pipe(debounceFn, tap(() => setQuerying(true)), switchMap(({ args, options }) => client.query(args, options)), tap(() => setQuerying(false))), [client]), options === null || options === void 0 ? void 0 : options.initial);
return { value, query, querying };
return useDebounce(client.query.bind(client), options);
};
export default useDebounceQuery;
//# sourceMappingURL=useDebounceQuery.js.map

@@ -1,19 +0,8 @@

import { debounce, ObservableInput, Subject } from 'rxjs';
import type { ObservableType } from '@equinor/fusion-observable';
import { UseDebounceOptions } from '@equinor/fusion-observable/react';
import Query, { QueryCtorOptions } from '../Query';
import { QueryOptions } from '../types';
type UseDebounceQueryArgs<TType, TArgs> = {
args: TArgs;
options?: QueryOptions<TType, TArgs>;
export declare const useDebounceQuery: <TType, TArgs>(clientOrClientCtor: Query<TType, TArgs> | QueryCtorOptions<TType, TArgs>, options: UseDebounceOptions<[TArgs]>) => {
value$: import("rxjs").Observable<import("..").QueryTaskCached<TType, TArgs> | import("../client").QueryTaskCompleted<TType, TArgs>>;
next: (args_0: TArgs) => void;
idle: boolean;
};
type UseDebounceQueryValue<TType, TArgs> = ObservableType<ReturnType<Query<TType, TArgs>['query']>>;
export declare const useDebounceQuery: <TType, TArgs>(clientOrClientCtor: Query<TType, TArgs> | QueryCtorOptions<TType, TArgs>, options: {
debounce: number | ((value: UseDebounceQueryArgs<TType, TArgs>) => ObservableInput<unknown>);
initial?: import("../types").QueryTaskCached<TType, TArgs> | import("../client").QueryTaskCompleted<TType, TArgs> | undefined;
queuer?: Subject<UseDebounceQueryArgs<TType, TArgs>> | undefined;
}) => {
value: import("../types").QueryTaskCached<TType, TArgs> | import("../client").QueryTaskCompleted<TType, TArgs> | undefined;
query: (args: UseDebounceQueryArgs<TType, TArgs>) => void;
querying: boolean;
};
export default useDebounceQuery;
{
"name": "@equinor/fusion-query",
"version": "0.3.1",
"version": "1.0.0",
"description": "WIP",

@@ -57,3 +57,3 @@ "private": false,

"dependencies": {
"@equinor/fusion-observable": "^2.5.0",
"@equinor/fusion-observable": "^3.0.0",
"immer": "^9.0.16",

@@ -81,3 +81,3 @@ "rxjs": "^7.5.7",

},
"gitHead": "909e48f515aa842e15eaeb26a7f75c160da39e84"
"gitHead": "b93e25b79c3b34ee46bd3a16b059e850acdffe95"
}

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