Is it possible to send multiple messages on one event using elm-html? -


i send 2 messages distinct adresses on 1 event. particular case encountered had popup , when user clicks "add" to:

  • close popup (message send popup component)
  • inform parent component item should added (message send parent component)

onclick has following type "address -> -> attribute" there seems no possibility that. on other hand seems such pattern (one action resulting in multiple message) met in practice.

for resorted sending 1 message informing parent item added , parent in update function updates popup hide action.

addbutton = button [onclick context.addtaskaddress model.taskdescription] [text "add"] 

and in parent's component update function

popup = addtaskpopup.update addtaskpopup.hide model.popup 

you set intermediate proxy mailbox takes list of address , message pairs, call button click.

proxy : mailbox (list (address a, a)) proxy =   mailbox [] 

then have broadcast signal listens proxy mailbox , creates bunch of signal.send tasks notify other addresses.

port broadcast : signal (task x (list ())) port broadcast =   let     tasks = list.map (uncurry signal.send)   in     signal.map (task.sequence << tasks) proxy.signal 

your onclick code this, pass in list of address , action pairs:

onclick proxy.address [(address, action1), (address, action2)] 

note in above code, address refers address coming view function, whereas proxy.address refers proxy mailbox set up.

this general purpose solution work number of signals.


Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

json - Gson().fromJson(jsonResult, Myobject.class) return values in 0's -