Hey there, I am working on a class and want to be able to categorize functions through objects. For example:
const client = new Client();
client.economy.transactions();
What would be the best way to implement this?
I have tried the following:
class Client {
public economy = {
transactions: () => {
// doing stuff here, in my use case I'd need `this` in here, so that's why the arrow function.
}
}
}
But that comes with two (or at least one) catch(es):
- In my use case, I'd need to be able to use overloading on functions like
transactions, which I can't , since this has to be an arrow function to havethis. - From what I read online, this being a property instead of a method directly on the class (and its prototype) is a problem, not entirely sure about why.
Does anyone know of any better way to implement this?