-
Robert Knight authored
Services in `src/sidebar/services` are effectively classes. They are currently implemented with a convention that was more common pre-ES6 where the constructor is a function that creates the fields as local variables and the methods using closures and returns an object that references the closures. This pattern has advantages, especially pre-ES6, as it avoids issues with incorrect use of `this` and hides internal state from consumers. However it also has downsides: - It is less obvious to readers that they are looking at something that is logically a class - This is not an idiom we use elsewhere in the codebase, where we use native classes instead - Static analysis tools don't support this pattern for creating a class as well as they support a native class. For example `TS` creates a named type for native classes, which is convenient to reference in JSDoc comments This commit starts a process of refactoring service classes to ES classes which are named `<Thing>Service`, using the router service as a first example. Per recently agreed conventions, the classes are named rather than default exports.
179271b7