Three penny-gi event and attribute combination

I have Event String

which I want sink

in a textbox. This works great, but now I want to match the current checkbox selection value with this line.

I first did this using a checkedChange

checkbox that works but has a problem. If a value is checked

included in this checkbox, the checkedChange-Event will not be checked, and the value displayed in the text box will not be updated as expected.

I could read the selection of a checkbox with get checked

, but then I ran into problems combining Event String

and UI Bool

(or UI String

when a boolean would be converted to a string).

EDIT: More precisely, I want to do something like

bCombinedValue <- stepper "" eCombinedValue
element textArea # sink UI.text bCombinedValue

      

where eCombinedValue

has the original Event String

and current value of the checked

checkbox attribute .

I could

bCheck <- stepper False $ UI.checkedChange checkBox

      

but it fails if i have

element checkBox # sink UI.checked bBool

      

elsewhere (no UI.checkedChange

).

I can use show <$> get UI.checked checkBox

, but then I would have to combine Event String

and UI String

.

+3


source to share


1 answer


This is intentional: the event is UI.checkedChange

fired only when the user clicks this checkbox, but not when it is programmatically checked. The behavior bBool

is assumed to represent the canonical state of the checkbox, and the event UI.checkedChange

is a request from the user to change it, which may or may not be provided. This allows bi-directional data flow ( see also ). Admittedly, "Tripenny" is not yet strictly adhering to these ideas.



In your case, I recommend integrating an event UI.checkedChange

into the behavior bBool

to represent the "canonical" state of the checkbox. If that doesn't work, just hack it with get UI.checked

and Reactive.Threepenny.unsafeMapIO

.

+4


source







All Articles