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

@cactuslab/api-helpers

Package Overview
Dependencies
Maintainers
3
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cactuslab/api-helpers - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

14

dist/hooks/usepromiseeffect.d.ts
import { DependencyList } from 'react';
export declare type PromiseEffectResult<T, E> = PromiseEffectResolved<T> | PromiseEffectRejected<E> | PromiseEffectInFlight<T, E>;
interface PromiseEffectResolved<T> {
export declare type PromiseEffectResult<T, E> = PromiseEffectStatus<T, E> & PromiseEffectFunctions<T, E>;
export declare type PromiseEffectStatus<T, E> = PromiseEffectResolved<T> | PromiseEffectRejected<E> | PromiseEffectInFlight<T, E>;
export interface PromiseEffectResolved<T> {
status: 'resolved';

@@ -8,3 +9,3 @@ result: T;

}
interface PromiseEffectRejected<E> {
export interface PromiseEffectRejected<E> {
status: 'rejected';

@@ -14,3 +15,3 @@ result?: undefined;

}
interface PromiseEffectInFlight<T, E> {
export interface PromiseEffectInFlight<T, E> {
status: 'inflight';

@@ -26,3 +27,3 @@ /**

}
interface PromiseEffectFunctions<T, E> {
export interface PromiseEffectFunctions<T, E> {
/**

@@ -41,4 +42,3 @@ * A function that when called triggers the original function to be called again, creating and resolving a new Promise.

*/
export declare function usePromiseEffect<T, E = unknown>(func: () => () => Promise<T>, deps: DependencyList): PromiseEffectResult<T, E> & PromiseEffectFunctions<T, E>;
export {};
export declare function usePromiseEffect<T, E = unknown>(func: () => () => Promise<T>, deps: DependencyList): PromiseEffectResult<T, E>;
//# sourceMappingURL=usepromiseeffect.d.ts.map
{
"name": "@cactuslab/api-helpers",
"version": "0.2.0",
"version": "0.2.1",
"description": "Helpers for integrating with a backend API.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

import { useCallback, useState, useEffect, DependencyList } from 'react'
export type PromiseEffectResult<T, E> = PromiseEffectResolved<T> | PromiseEffectRejected<E> | PromiseEffectInFlight<T, E>
export type PromiseEffectResult<T, E> = PromiseEffectStatus<T, E> & PromiseEffectFunctions<T, E>
interface PromiseEffectResolved<T> {
export type PromiseEffectStatus<T, E> = PromiseEffectResolved<T> | PromiseEffectRejected<E> | PromiseEffectInFlight<T, E>
export interface PromiseEffectResolved<T> {
status: 'resolved'

@@ -11,3 +13,3 @@ result: T

interface PromiseEffectRejected<E> {
export interface PromiseEffectRejected<E> {
status: 'rejected'

@@ -18,3 +20,3 @@ result?: undefined

interface PromiseEffectInFlight<T, E> {
export interface PromiseEffectInFlight<T, E> {
status: 'inflight'

@@ -31,3 +33,3 @@ /**

interface PromiseEffectFunctions<T, E> {
export interface PromiseEffectFunctions<T, E> {
/**

@@ -48,3 +50,3 @@ * A function that when called triggers the original function to be called again, creating and resolving a new Promise.

*/
export function usePromiseEffect<T, E = unknown>(func: () => () => Promise<T>, deps: DependencyList): PromiseEffectResult<T, E> & PromiseEffectFunctions<T, E> {
export function usePromiseEffect<T, E = unknown>(func: () => () => Promise<T>, deps: DependencyList): PromiseEffectResult<T, E> {
const [version, setVersion] = useState(0)

@@ -54,3 +56,3 @@

func = useCallback(func, deps)
const [result, setResult] = useState<PromiseEffectResult<T, E>>({
const [result, setResult] = useState<PromiseEffectStatus<T, E>>({
status: 'inflight',

@@ -57,0 +59,0 @@ })

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