mirror of
https://gitlab.nic.cz/turris/reforis/foris-js.git
synced 2024-12-25 00:11:36 +01:00
Add default delay.
This commit is contained in:
parent
2e68e56e44
commit
73e213c467
|
@ -5,14 +5,10 @@
|
||||||
* See /LICENSE for more information.
|
* See /LICENSE for more information.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import { useCallback, useEffect, useReducer, useState, } from "react";
|
||||||
useCallback, useEffect, useReducer, useState,
|
|
||||||
} from "react";
|
|
||||||
|
|
||||||
import { ForisURLs } from "forisUrls";
|
import { ForisURLs } from "forisUrls";
|
||||||
import {
|
import { API_ACTIONS, API_METHODS, API_STATE, getErrorPayload, HEADERS, TIMEOUT, } from "./utils";
|
||||||
API_ACTIONS, API_METHODS, API_STATE, getErrorPayload, HEADERS, TIMEOUT,
|
|
||||||
} from "./utils";
|
|
||||||
|
|
||||||
const DATA_METHODS = ["POST", "PATCH", "PUT"];
|
const DATA_METHODS = ["POST", "PATCH", "PUT"];
|
||||||
|
|
||||||
|
@ -93,7 +89,7 @@ export {
|
||||||
useAPIGet, useAPIPost, useAPIPatch, useAPIPut, useAPIDelete,
|
useAPIGet, useAPIPost, useAPIPatch, useAPIPut, useAPIDelete,
|
||||||
};
|
};
|
||||||
|
|
||||||
export function useAPIPolling(endpoint, delay) {
|
export function useAPIPolling(endpoint, delay = 1000) { // delay ms
|
||||||
const [state, setState] = useState({ state: API_STATE.INIT });
|
const [state, setState] = useState({ state: API_STATE.INIT });
|
||||||
const [getState, get] = useAPIGet(endpoint);
|
const [getState, get] = useAPIGet(endpoint);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user