This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Observable, animationFrameScheduler, fromEvent, of } from "rxjs"; | |
| import { distinctUntilChanged, filter, map, pairwise, switchMap, throttleTime } from "rxjs/operators"; | |
| import { ScrollType, ScrollMovement } from "./types"; | |
| export const watchScroll$ = (): Observable<ScrollType> => | |
| of(typeof window === "undefined") | |
| .pipe( | |
| filter((undefinedWindow) => (!undefinedWindow)), | |
| switchMap(() => fromEvent(window, "scroll", {passive: true})), | |
| throttleTime(0, animationFrameScheduler), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Observable, animationFrameScheduler, fromEvent, of } from "rxjs"; | |
| import { distinctUntilChanged, filter, map, pairwise, switchMap, throttleTime } from "rxjs/operators"; | |
| import { ScrolType, ScrollMovement } from "./types"; | |
| export const watchScroll$ = (): Observable<ScrollType> => | |
| of(typeof window === "undefined") | |
| .pipe( | |
| filter((undefinedWindow) => (!undefinedWindow)), | |
| switchMap(() => fromEvent(window, "scroll", {passive: true})), | |
| throttleTime(0, animationFrameScheduler), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const axios = require('axios') | |
| const doRequest = () => { | |
| try { | |
| return axios.get('https://thegreatapi.org/v1') | |
| } catch (error) { | |
| console.error(error) | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import {setupInterceptorsTo} from "./Interceptors"; | |
| import axios from "axios"; | |
| const specificAxios = setupInterceptorsTo(axios.createInstance()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import {setupInterceptorsTo} from "./Interceptors"; | |
| import axios from "axios"; | |
| setupInterceptorsTo(axios); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const myInterceptor = axios.interceptors.request.use(function () {/*...*/}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import {AxiosError, AxiosInstance, AxiosRequestConfig, AxiosResponse} from "axios"; | |
| const onRequest = (config: AxiosRequestConfig): AxiosRequestConfig => { | |
| console.info(`[request] [${JSON.stringify(config)}]`); | |
| return config; | |
| } | |
| const onRequestError = (error: AxiosError): Promise<AxiosError> => { | |
| console.error(`[request error] [${JSON.stringify(error)}]`); | |
| return Promise.reject(error); |