# show map of messages, display map in Page() after a change
import solara
store={'one':'message 1','two':'*message 2*','three':'__message 3__'}
@solara.component
def MarkdownEditor(fld:str):
md, set_md = solara.use_state(store[fld])
def propagate(newval):
set_md(newval)
store[fld]=newval # update map
process_it = 1 # trigger display of map in Page()
print(store) # proof that on_value was triggered
with solara.VBox() as main:
solara.InputText('value '+fld,value=md, on_value=propagate)
solara.Markdown(md)
return main
@solara.component
def Page():
def process_it_rtn(): # process update on any of the map fields
print('changed?')
process_it = 0
process_it = solara.use_reactive(0,process_it_rtn)
for fld in store.keys():
MarkdownEditor(fld)
if process_it.value==1: # process update on any of the map fields
solara.Markdown(str(store))
process_it = 0