Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the constructor to construct cancellation #16

Open
ysmood opened this issue Jul 27, 2015 · 0 comments
Open

Use the constructor to construct cancellation #16

ysmood opened this issue Jul 27, 2015 · 0 comments

Comments

@ysmood
Copy link

ysmood commented Jul 27, 2015

I have implemented my draft. It's very simple and should also work for progress. You can find the lib here yaku, and test it yourself. Here's the example:

let Promise = require('yaku')

// The `this` is the instance of the newly created promise.
let p = new Promise((resolve, reject) => {
    let tmr = setTimeout(resolve, 3000)

    let this.abort = () => {
        clearTimeout(tmr)
        reject(new Error('abort promise'))
    }

})

p.abort()

It's simple and flexible.

@ysmood ysmood changed the title Use the constructor to construct cancellation Use the constructor to construct cancellate Jul 27, 2015
@ysmood ysmood changed the title Use the constructor to construct cancellate Use the constructor to construct cancellation Jul 27, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant