Open scottohara opened 6 years ago
In @typescript-eslint@5.18.0
, the no-this-alias
rule was improved to catch more assignment of this
.
As such, we started to get warnings about ApplicationController.singletonInstance = this;
To address, we have temporarily disabled the rule, but will look to re-enable after changing from a singleton-instance to a service.
(Note: there is one other instance of this rule violation in spec/public/mocks/window-mock.ts
, where this.window = this
. This may mean we need to keep the rule disabled via spec/public/.eslintrc.json
)
Anywhere we need a reference to the app controller, we create a new instance of one, e.g.
However, under the covers, it actually behaves like a singleton object. For example:
(it does this by storing a reference to itself in the private static
singletonInstance
property, and the constructor returns this reference on the second and any subsequent calls)Given this, and the fact that the
*Controller
naming convention is intended for 'view controllers' (i.e. classes that extendViewController
), it would be more appropriate to:ApplicationController
toApplicationService
/controllers/application-controller.ts
to/services/application-service.ts
start()
)ApplicationController
instances in other classes, and simply referenceApplicationController
as a static singleton service.