progress-loader-node
v1.1.5
Published
```sh $ npm i progress-loader-node ```
Downloads
785
Maintainers
Readme
Usage
Installation
$ npm i progress-loader-node
Example Loader
import { Loader } from 'progress-loader-node'
async function ConfigDB() {
const loader = Loader.start(`Configurar la base de datos`)
try {
await new Promise(resolve => setTimeout(resolve, 3000))
Loader.stop(loader)
} catch (error) {
Loader.stop(loader, true)
}
}
ConfigDB()
Example useLoader
import { useLoader } from 'progress-loader-node'
async function initDB() {
await new Promise(resolve => setTimeout(resolve, 2000))
}
async function initControllers() {
await new Promise((_, reject) => setTimeout(() => reject({ message: 'Tiempo de espera excedido' }), 2000))
}
async function initProcces() {
await new Promise(resolve => setTimeout(resolve, 2000))
}
async function initServer() {
await useLoader(initDB, 'Iniciar base de datos')
await useLoader(initControllers, 'Iniciar Controladores')
await useLoader(initProcces, 'Iniciar Procesos')
}
initServer()
Example useLoaderWithError
import { useLoaderWithError } from 'progress-loader-node'
async function initDB() {
await new Promise(resolve => setTimeout(resolve, 2000))
}
async function initControllers() {
await new Promise((_, reject) => setTimeout(() => reject({ message: 'Tiempo de espera excedido' }), 2000))
}
async function initProcces() {
await new Promise(resolve => setTimeout(resolve, 2000))
}
async function initServer() {
await useLoaderWithError(initDB, 'Iniciar base de datos')
await useLoaderWithError(initControllers, 'Iniciar Controladores')
await useLoaderWithError(initProcces, 'Iniciar Procesos')
}
initServer()