It is very unusual for me that if I wrote my class in TypeScript and call it something like this:
var result = new MyClass.search(...) That search() method will be called before the constructor finishes, if the constructor has to use asynchronous functions (node.js I / O). That is, the constructor has not yet completed the initialization of the object, and someone already calls the object's methods. Is it possible to do something similar (analogue spend with WinAPI):
search(...) { waitForSingleObject(event) ... } And while the designer does his work and does not cause:
setEvent(event) then the search() method will slow down? At the same time, of course, waitForSingleObject() should be a smart function and make it clear to the thread that while you can do other things and not slow down, say, the entire node.js platform?
PS I understand that the problem is not in TypeScript. In JS, the constructor function can also create methods for this and return control before it receives initialization data over the network, from the database, from the disk subsystem, etc.
waitForSingleObjectyou can useasync/await. - Vladimir Gamalyan