How to handle request/response propagation up and down a widget hierarchy in a GUI app?

Posted by fig-gnuton on Stack Overflow See other posts from Stack Overflow or by fig-gnuton
Published on 2010-06-14T21:19:35Z Indexed on 2010/06/14 21:22 UTC
Read the original article Hit count: 124

Given a GUI application where widgets can be composed of other widgets: If the user triggers an event resulting in a lower level widget needing data from a model, what's the cleanest way to be able to send that request to a controller (or the datastore itself)? And subsequently get the response back to that widget?

Presumably one wouldn't want the controller or datastore to be a singleton directly available to all levels of widgets, or is this an acceptable use of singleton? Or should a top level controller be injected as a dependency through a widget hierarchy, as far down as the lowest level widget that might need that controller? Or a different approach entirely?

© Stack Overflow or respective owner

Related posts about best-practices

Related posts about gui