0

I have designed a app using mithriljs(0.2.5) with components and Observer pattern for inter-component communication. However I do have a requirement of blocking an action of component based on another one.

Say, I have 2 components ItemList & ItemDetail. When an Item is selected in the list component an ITEM_SELECTED event is fired that causes the detail to be loaded. Detail component allows user details to be edited and saved.

If the details are dirty(edited not saved) and user tries to do an selection, I want to show a Save Item screen with Yes/No/Cancel option. Based on the option selected either load new details or cancel and go back to previous selection.

Selection component has no knowledge of dirtiness of the details, Detail component will render the Save Confirmation.

One option for the Detail component to fire a REVERT_SELECTION message if cancel is selected, ideal pattern would be to block the Item selection completion till Detail components gives a go/no go response, seems I need something other than observer, which is blocking.

Thanks

chifer
  • 683
  • 5
  • 19
  • Just out of curiosity, have you considered migrating to Mithril 1.x yet? It's been out for about 5 months at this point, so it is something you may want to consider soon. – Claudia Jun 20 '17 at 15:46
  • @Isiah Meadows, in short we have, We started the project with Mithril 0.1x, in mid 2014, it is quite complex and large. Mitriljs has been awesome(thanks!), specially the dom management/rendering performance. We have used lot of Mithriljs 0.x patterns and featured like m.prop, m.sync. m.start/endComputation(project is based on websockets). We do have 3 party libs(jQuery,jQueryUI, Gridstack, C3js..) hence heavy use of vdom.config. Looking at 1.0 api the migration will not be straight forward it would be a significant refactor to get the full benefit of the v1.x. This is holding us back – chifer Jun 21 '17 at 22:11

1 Answers1

0

I suppose the best solution would be to use a Modal Dialog that will block all the GUI unti a selection on Yes/No/Cancel is done.

Im mithril 0.2.5 you varios approact available for modals.

Please take a look to this samples

Fabiano Taioli
  • 5,270
  • 1
  • 35
  • 49