Skip to content

Run promise in isReady instead of constructor#139

Open
mborne wants to merge 1 commit intocamptocamp:mainfrom
mborne:main
Open

Run promise in isReady instead of constructor#139
mborne wants to merge 1 commit intocamptocamp:mainfrom
mborne:main

Conversation

@mborne
Copy link
Copy Markdown

@mborne mborne commented Apr 18, 2026

It will avoid unhandledRejection from the constructor

(refs #138)

@mborne
Copy link
Copy Markdown
Author

mborne commented Apr 18, 2026

Tell me if you are interrested in some hardening like the following in this PR or another one :

  • "ensure that isReady() is called" to avoid misuse of the class.
  • param initialization (i'm leaving the warning Property '_info' has no initializer and is not definitely assigned in the constructor. to avoid noise)
  • type completion and comment fixing

Something like :

class WfsEndpoint {
  /**
   * A Promise which resolves to the endpoint information.
   */
  getServiceInfo() {
    return this._info;
  }
}

=>

class WfsEndpoint {
  
  // ...

  ensureIsReady(){
     if ( ! this._info ){
         throw new EndError("isReady() must be resolved before calling WfdEndpoint methods")
     }
  }

  /**
   * Get the endpoint information.
   */
  getServiceInfo(): GenericEndpointInfo {
    this.ensureIsReady();
    return this._info;
  }

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant