title: How to implement NativeScript Class in TypeScript with self delegate?
body: <p>I am creating a NativeScript plugin that wrap a <a href="https://github.com/xmlking/MicrosoftBand" rel="nofollow noreferrer">Swift CocoaPod</a> lib.</p>
  
  <p>In my <a href="https://github.com/xmlking/nativescript-ngx-microsoftband/blob/master/src/app/services/microsoftband.service.ios.ts#L45" rel="nofollow noreferrer">NativeScript plugin</a>, I am using a separate class to add required <a href="https://github.com/xmlking/nativescript-ngx-microsoftband/blob/master/src/app/services/microsoftband.service.ios.ts#L493" rel="nofollow noreferrer">delegate</a> to main class.</p>
  
  <p>Will it be possible to implement delegate methods in main class and avoid the delegate class completely?</p>
  
  <p>i.e., </p>
  
  <pre><code>export class MicrosoftBandService  extends NSObject implements ConnectionDelegate {
  
    static new(): MicrosoftBandService {
      return &lt;MicrosoftBandService&gt;super.new()
    }
  
    constructor() {
      let _self= this;
      this.mbk = MicrosoftBand.alloc().init();
      this.mbk.connectDelegate = _self
    }
  
    onConnecte() {
      //
  
    onDisconnecte() {
      //
    }
  
    onErrorWithError(error) {
      //
    }
  
  }
  </code></pre>
  
  <p>even better, I like to do like this</p>
  
  <pre><code>export class MicrosoftBandService  extends MicrosoftBand implements ConnectionDelegate {
  
    static new(): MicrosoftBandService {
      return &lt;MicrosoftBandService&gt;super.new()
    }
  
    constructor() {
      let _self= this;
      this.connectDelegate = _self
    }
  
    onConnecte() {
      //
    }
  
      onDisconnecte() {
        //
      }
  
      onErrorWithError(error) {
        //
      }
  
    }
  </code></pre>
  
  <p>I don't know proper syntax to implement constructor with self delegate in TypeScript for NativeScript </p>
  
  <p>My current code works, but I am looking for help to simplify and reduce code by eliminating separate delegate class.  </p>