title: Referncing decorated class method with this context intact
body: <p>I'm writing a short decorator helper function to turn a class into an event listener</p>
  
  <p>My problem is that the decorators will register the decorated method as a callback for incoming events, but the decorated method won't retain it's original <code>this</code> context.</p>
  
  <p>Main question how can I retain the <code>this</code> context of the decorated method in this scenario?</p>
  
  <p>Implementation:</p>
  
  <pre><code>export function EventHandler (topicKey: any): ClassDecorator {
      return function (target: any) {
          const subscriptions = Reflect.getMetadata('subscriptions', target.prototype)
  
          const topic = Container.get&lt;DomainTopicInterface&gt;(topicKey)
          topic.subscribe(event =&gt; {
              if (subscriptions.length === 0) {
                  throw new Error(`Event received for '${target.constructor.name}' but no handlers defined`)
              }
              subscriptions.forEach((subscription: any) =&gt; {
                  subscription.callback(event) // &lt;---- the this context is undefined
              })
          })
  
          return target
      }
  }
  
  export function Subscribe (targetClass: StaticDomainEvent&lt;any&gt;): MethodDecorator {
      return function (target: Function, methodName: string, descriptor: TypedPropertyDescriptor&lt;any&gt;) {
          let originalMethod = descriptor.value
          let subscriptions = Reflect.getMetadata('subscriptions', target)
          if (!subscriptions) { Reflect.defineMetadata('subscriptions', subscriptions = [], target) }
  
          subscriptions.push({
              methodName,
              targetClass,
              callback: originalMethod
          })
      }
  }
  </code></pre>
  
  <p>Example usage:</p>
  
  <pre><code>@EventHandler(Infra.DOMAIN_TOPIC)
  export class JobHandler {
  
      constructor (
          @Inject() private service: JobService
      ) {}
  
      @Subscribe(JobCreated)
      jobCreated (events: Observable&lt;JobCreated&gt;) {
          console.log(this) // undefined
      }
  
  }
  </code></pre>