UNPKG

@bzxnetwork/portal

Version:
22 lines (17 loc) 533 B
import React from "react"; import { makeCancelable as m } from "./utils"; export default class BZxComponent extends React.Component { promiseList = []; componentWillUnmount() { this.promiseList.forEach(function(p) { p.cancel(); //console.log(`cancel promise`); }); } makeCancelable = m; wrapAndRun = async (promise) => { const p = await this.makeCancelable(promise); await this.promiseList.push(p); return p.promise; }; }