denim-ui
denim-ui copied to clipboard
TextInput needs text to be Observable[string]. Doesn't work for Subject[string]
component MyInput(state: Subject[string]):
stack(width = 200.0):
text(text = "", alignment = Alignment.Center, color = black)
textInput(
alignment = Alignment.Left,
text <- state,
color = black,
minWidth = 100.0,
placeholder = "...insert text",
onChange =
proc(x: string): void {.closure.} =
state <- x
echo("newVal: ", x)
,
)
fails but
component MyInput(state: Subject[string]):
stack(width = 200.0):
text(text = "", alignment = Alignment.Center, color = black)
textInput(
alignment = Alignment.Left,
text <- state.source,
color = black,
minWidth = 100.0,
placeholder = "...insert text",
onChange =
proc(x: string): void {.closure.} =
state <- x
echo("newVal: ", x)
,
)
works