Add a simple loading spinner to your async JS calls - built for the browser.
MIT License
Add a simple loading spinner to your async JS calls - built for the browser.
$ npm install --save use-spinner
import useSpinner from 'use-spinner';
import 'use-spinner/assets/use-spinner.css';
const fn = async () => {
await new Promise(resolve => setTimeout(() => {
console.log('done.');
resolve();
}, 2000));
};
// wrap your asynchronous function
const spinnedFn = useSpinner(fn, {
container: 'body'
});
// execute with a loading spinner
await spinnedFn();
The API accepts a second argument configuring the wrapped function. This defaults to:
{
container: 'body'
}
MIT