Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

async function in constructor class typescript

// Don't put the object in a promise, put a promise in the object.

class Foo {
  public Ready: Promise.IThenable<any>;
  constructor() {
    ...
    this.Ready = new Promise((resolve, reject) => {
      $.ajax(...).then(result => {
        // use result
        resolve(undefined);
      }).fail(reject);
    });
  }
}

var foo = new Foo();
foo.Ready.then(() => {
  // do stuff that needs foo to be ready, eg apply bindings
});
// keep going with other stuff that doesn't need to wait for foo

// using await
// code that doesn't need foo to be ready
await foo.Ready;
// code that needs foo to be ready
Comment

PREVIOUS NEXT
Code Example
Typescript :: subscripts list c# 
Typescript :: hhow to remove elements from java 
Typescript :: material ui tab link external 
Typescript :: google sheets formula pull last columns 
Typescript :: amqplib 
Typescript :: cant find the name console 
Typescript :: Returns number of valuesDisplays the number in brackets of return value 
Typescript :: google sheets automatic update rook 
Typescript :: The Apple I had a built-in video terminal, sockets for __________ kilobytes of onboard random access memory (RAM), a keyboard, and a cassette board meant to work with regular cassette recorders. 
Typescript :: paste elements of a vector r 
Typescript :: ts in r 
Typescript :: You will use an appropriate looping statement to write a script that displays a list of the Celsius equivalents of zero degrees Fahrenheit through 100 degrees Fahrenheit 
Typescript :: How to check that tuple A contains all elements of tuple B python? 
Typescript :: how to check if object contains a certien key in ts using jasmin 
Typescript :: four basic components that information system consists of 
Typescript :: how to get the elements of a pair scheme 
Typescript :: How to disabele and enable the button when it valid 
Typescript :: Use AuthGuard with gRPC Metadata 
Typescript :: typescript type casting 
Typescript :: spread types may only be created from object types firebase 
Typescript :: github actions typescript 
Typescript :: how to call an action from another action in redux 
Typescript :: add and edit in ionic page 
Typescript :: breaks_width in r 
Typescript :: typescript list 
Typescript :: token authentication requirements for git operations 
Typescript :: democrats are pussies 
Cpp :: dart async function 
Cpp :: print stack c++ 
Cpp :: how to check datatype of a variable in c++ 
ADD CONTENT
Topic
Content
Source link
Name
3+6 =