import Worker from "worker-loader!../Worker" ; class Generator { private worker : Worker ; constructor ( ) { this . worker = new Worker ( ) ; } generate ( ) { return new Promise ( ( resolve ) => { this . worker . addEventListener ( "message" , ( event ) => resolve ( event . data . imagedata ) , { once : true } ) ; this . worker . postMessage ( null ) ; } ) ; } } export const generator = new Generator ( ) ;