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 useNativeSWR from 'swr' | |
import { useRef } from 'react' | |
// inspired by https://github.com/vercel/swr/discussions/456 | |
export default function useSWR(key, fetcher, options = {}) { | |
const { cachePolicy, ...opts } = options | |
const random = useRef(new Date()) | |
return useNativeSWR( | |
() => { |
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
// licensed under public domain | |
// author: [email protected] | |
const EventEmitter = require('events') | |
// K combinator, not necessary, just for fun | |
const K = x => y => x | |
// this class is mainly for settle logic. | |
// the concrete class should emit a 'finish' event with err/data at the end of the process |