mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2024-12-19 13:47:54 +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 |
||
---|---|---|
.. | ||
api-binder | ||
compose | ||
config | ||
device-api | ||
device-state | ||
lib | ||
logging | ||
migrations | ||
types | ||
app.ts | ||
db.ts | ||
device-config.ts | ||
device-state.ts | ||
event-bus.ts | ||
event-tracker.ts | ||
host-config.ts | ||
local-mode.ts | ||
logger.ts | ||
network.ts | ||
proxyvisor.js | ||
supervisor-api.ts | ||
supervisor.ts |