
Product
Introducing Repository Labels and Security Policies
Socket is introducing a new way to organize repositories and apply repository-specific security policies.
@data-client/core
Advanced tools
Async State Management without the Management. REST, GraphQL, SSE, Websockets, Fetch
Reducer/flux normalized, framework-agnostic data store. Includes managers/middleware, global referential equality guarantees, automatic expiry policies, data normalization. Consumes TypeScript Standard Endpoints
function useSuspense(endpoint, ...args)
const state = useCacheState();
const controller = useController();
const key = args[0] !== null ? endpoint.key(...args) : '';
const cacheResults = key && state.endpoints[key];
const meta = state.meta[key];
// Compute denormalized value
const { data, expiryStatus, expiresAt } = useMemo(() => {
return controller.getResponse(endpoint, ...args, state);
}, [
cacheResults,
state.indexes,
state.entities,
state.entityMeta,
meta,
key,
]);
const error = controller.getError(endpoint, ...args, state);
// If we are hard invalid we must fetch regardless of triggering or staleness
const forceFetch = expiryStatus === ExpiryStatus.Invalid;
const maybePromise = useMemo(() => {
// null params mean don't do anything
if ((Date.now() <= expiresAt && !forceFetch) || !key) return;
return controller.fetch(endpoint, ...args);
// we need to check against serialized params, since params can change frequently
}, [expiresAt, controller, key, forceFetch, state.lastReset]);
// fully "valid" data will not suspend even if it is not fresh
if (expiryStatus !== ExpiryStatus.Valid && maybePromise) {
throw maybePromise;
}
if (error) throw error;
return data;
}
FAQs
Async State Management without the Management. REST, GraphQL, SSE, Websockets, Fetch
The npm package @data-client/core receives a total of 896 weekly downloads. As such, @data-client/core popularity was classified as not popular.
We found that @data-client/core demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket is introducing a new way to organize repositories and apply repository-specific security policies.
Research
Security News
Socket researchers uncovered malicious npm and PyPI packages that steal crypto wallet credentials using Google Analytics and Telegram for exfiltration.
Product
Socket now supports .NET, bringing supply chain security and SBOM accuracy to NuGet and MSBuild-powered C# projects.