Hi, Normally when I create a service, that service is a singleton. But how I declare a ‘class’ and make instances of it? And where do I put them?
For example, I want to create three types of errors ‘classes’ and I want to create objects with them.
Hi, Normally when I create a service, that service is a singleton. But how I declare a ‘class’ and make instances of it? And where do I put them?
For example, I want to create three types of errors ‘classes’ and I want to create objects with them.
We usually use a ‘util’ for that sort of thing. I could be way off here but AFAIK a util is basically a catch-all general javascript class/function/object mechanism. I think utils were meant to be functions but you can export anything from them so they’re a good general purpose project item for anything. For example in our project we export an object with sort functions, then when we import the util we use them via sortFunctions.<sortFunctionName>
Thanks for the answer.