1.0.4 ā€¢ Published 3 years ago

are-you-ready-yet v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Are you ready yet?

npm-badge

The are-you-ready-yet package is basically a joke on Promise.

Sometime you have to use your imagination to figure out what would be useful of this package.
It might be keep you waiting for an answer, you'll never know!

šŸ˜‚ Ā Good luck!

Install

npm install are-you-ready-yet
# or
yarn add are-you-ready-yet

Usage

import { areYouReadyYet } from 'are-you-ready-yet'

class DoSomething {
    constructor() {
        this.ready = areYouReadyYet()

        // Now setup the instance
        // Once you are ready!
        this.setup()
    }

    async setup() {
        // Fake task to do something that take a very long time
        setTimeout(() => this.ready.yes(), 5000)

        // If you want to throw error
        // this.ready.no(new Error('Your error message'))
    }
    

    /**
     * Wait for `maybe` to resolve
     */
    async doThat() {
        console.log("I'll do that after i'm ready!")
        await this.ready.maybe()
        console.log('I did it!')
    }
}

const do = new DoSomething()

do.doThat() // Promise
// This will output "I'll do that after i'm ready!"
// then wait until the `setTimeout` callback executed 
// and output "I did it!"

Example of are-you-ready-yet used with GoogleChromeLabs/comlink. Click here.

License

Licensed under MIT License

1.0.4

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

1.0.3

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago