• Robert Knight's avatar
    Convert `router` service to a native ES class · 179271b7
    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
Name
Last commit
Last update
..
components Loading commit data...
config Loading commit data...
helpers Loading commit data...
services Loading commit data...
store Loading commit data...
test Loading commit data...
util Loading commit data...
cross-origin-rpc.js Loading commit data...
icons.js Loading commit data...
index.js Loading commit data...
markdown-commands.js Loading commit data...
media-embedder.js Loading commit data...
render-markdown.js Loading commit data...
search-client.js Loading commit data...
service-context.js Loading commit data...
websocket.js Loading commit data...