this post was submitted on 18 Jul 2023
1 points (100.0% liked)

Programming Help

44 readers
3 users here now

There are no stupid questions.

founded 1 year ago
MODERATORS
 

I have currently:

A Class with multiple functions A Decorator that saves the function to a list

The problem:

When i call the function "this" is not the class ( or not yet initialized )

How can i implement it correctly?

My Class Function Decorator:

export function LemmyOn(data: ILemmyOn) {  

  return function (  
    target: Object,  
    propertyKey: string | symbol,  
    descriptor: TypedPropertyDescriptor<any>  
  ) {  

    events.push({ data: data, fn: descriptor.value });  
    return descriptor;  
  };
}
no comments (yet)
sorted by: hot top controversial new old
there doesn't seem to be anything here