✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
⚡️ Concerned about the grid? Kyle Baranko teaches how to predicting peak loads using XGBoost. Register for the August webinar!

Show fig while updating it

hello, i have a callback that returns a fig. the call back draws a neural network, and as you might have guessed, there are lots of loops involved. the figure is returned after the last loop. but i would like to show the figure after each loop. i tried fig.show() but that just opens a new tab. here is my code, please help.

@app.callback(

        Output('result','figure'),
        [Input('c','n_clicks')],
        [State('output','children')]
    )

def get_result(n_clicks,children):
 
    hidden_layers  = [x['props'].get('value') for x in children if type(x['props'].get('value')) == int and x['props'].get('value')!=0]  
    fig['layout']['shapes'] = []  # clear shapes (circles)
    fig['data'] = []  # clear connections
    horizontal_distance_between_layers = 0
    if children:

        for layer_number,layer in enumerate(hidden_layers):
            center_layer_vertically =  (max(hidden_layers) - layer) / 2
            connect_to_previous_layer = True if not_first_layer(layer_number) else False   
            draw_layer(layer,center_layer_vertically,horizontal_distance_between_layers,connect_to_previous_layer)
            horizontal_distance_between_layers +=5
    else:
        return fig


    fig.update_layout(width=800, height=800)
    return fig

you can put your for-loop outside the callback.

i am really new to dash, can you please elaborate ? an example would be nice.

thanks in advance