I have 200 toggle switches on my page, with 200 callbacks to do things with them obviously. They initialize very quickly. But, I added a single button to “TOGGLE ALL ON/OFF” that makes all 200 toggles turn on or off. After adding this control, and the callback with 200 corresponding outputs, the app initialization now takes 20+ seconds.
This is the callback causing the problems:
#Enforce-All button
outputList=[]
#loop to fill outputList
for i in range(0,maxNumInvCards):
outputList.append(Output(str(i)+'-enforce', 'on' ))
@app.callback(outputList,
[Input('enforce-all-button','n_clicks_timestamp'),
Input('disable-all-button','n_clicks_timestamp')])
def enforce_all(enforce_all_ts, disable_all_ts):
returnList=[]
if not enforce_all_ts:
enforce_all_ts=0
if not disable_all_ts:
disable_all_ts=0
if disable_all_ts > enforce_all_ts:
for i in range(0,maxNumInvCards):
returnList.append(False)
else:
for i in range(0,maxNumInvCards):
returnList.append(True)
return returnList