Skip to content

Use the constructor to construct cancellation #16

@ysmood

Description

@ysmood

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions