mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2024-12-23 15:32:24 +00:00
48e0733c7e
The supervisor uses the following pattern for async module initialization ```typescript // module.ts export const initialised = (async () => { // do some async initialization })(); // somewhere else import * as module from 'module'; async function setup() { await module.initialise; } ``` The above pattern means that whenever the module is imported, the initialisation procedure will be ran, which is an anti-pattern. This converts any instance of this pattern into a function ```typescript export const initialised = _.once(async () => { // do some async initialization }); ``` And anywhere else on the code it replaces the call with a ```typescript await module.initialised(); ``` Change-type: patch |
||
---|---|---|
.. | ||
application-state-mock.ts | ||
chai.ts | ||
db-helper.ts | ||
errors.ts | ||
helpers.ts | ||
mocked-balena-api.ts | ||
mocked-database.ts | ||
mocked-dbus.ts | ||
mocked-device-api.ts | ||
mocked-dockerode.ts | ||
mocked-iptables.ts | ||
mockerode.ts | ||
prepare.ts |