Hi David, Thanks for the reply. I had read the todo sample but somehow I missed that. The missing ingredient was the fn function passed on the build params hash.
About the channels I agree its a great way to decouple things. I just thought that creating channels all the time could get messy but I will give it a try. Passing info upstream the component hierarchy is bound to get a bit more complex if you want to keep things decoupled. On Thursday, April 3, 2014 7:27:47 PM UTC+3, David Nolen wrote: > Have you looked at how editing is handled in the Om version of TodoMVC? > http://github.com/swannodette/todomvc/blob/gh-pages/labs/architecture-examples/om/src/todomvc/app.cljs > > > > Callbacks and channels are both fine for inter-component communication and > unlikely to get "unwieldy". This would be accomplished similarly with events > in plain JavaScript to allow for loose coupling. > > > > > > > > > David > > > > On Thu, Apr 3, 2014 at 12:11 PM, Dimitris Stefanidis <[email protected]> > wrote: > > Hi All, > > > > I have been following closely all the discussions related to om and > application architecture best practices. I have the same problems described > in the following thread > https://groups.google.com/forum/#!topic/clojurescript/SiRxM0HSoRk > > > > > I would like to describe a couple of scenarios that with my current om > understanding seem very hard to model. > > > > I have a list of transactions. Transactions look like this. > > [{:amount 10 :description "10 dollars" :created_at "03/04/2014"} > > {:amount 20 :description "20 dollars" :created_at "04/04/2014"}] > > > > I have a transactions-view component that renders one transaction-component > for every transaction. > > > > The transaction-component renders 3 editable-view components on for each key > of the transaction hash. > > > > The user can edit the amount, description and created_at fields for each list > item by double clicking on them. This works fine. What I would like to > achieve now is the ability to jump in edit mode from field to field and from > transaction to transaction kind of like an excel sheet. When the user clicks > enter while editing the amount of a transaction the amount of the transaction > below it should go into editing state with the cursor in focus. Similarly > when he clicks tab while editing the amount the description of the same > transaction should go into edit mode and editing should end on the amount > field. > > > > > This has me stumped for quite a few reasons some of them described below. > > > > 1. The editing flag should go in the transaction. There is no way to store it > in component state as it is currently being done for the editable-view > component. Some parent view will need to set the transaction in editing mode. > However the editing flag has nothing to do with the business logic of the > application. What if the same transaction is displayed on another place of > the app at the same time and I don't want it to be editable there. Is it > possible to pass a cursor that wraps the transaction somehow ? The equivalent > of a view model. Still this should be accessible to the parent. > > > > > 2. How would I pass information to parent views that editing stopped with > enter or editing stopped with tab. Channels seem like a viable option here or > maybe a simple callback on the parent. Both those solutions I feel get > unwieldy really fast as the complexity of the application grows. Maybe a > simple pub channel with commands and events that everyone can listen to. > Still not the best of solutions. > > > > > Similar problems appear with a simpler use case which is multiple selection > of transaction views and summarisation of them on side panel. How do we > maintain state of selected transactions ? Do we store them on an other list > called selected-transactions in our state ? If I edit a selected transaction > from the selected-list how is this going to be propagated to the server and > to the main transactions list. Do we put a selected flag to the transaction ? > Again what happens if this transaction is displayed on another place in the > ui and should not be selected ? > > > > > -- > > Note that posts from new members are moderated - please be patient with your > first post. > > --- > > You received this message because you are subscribed to the Google Groups > "ClojureScript" group. > > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > > To post to this group, send email to [email protected]. > > Visit this group at http://groups.google.com/group/clojurescript. -- Note that posts from new members are moderated - please be patient with your first post. --- You received this message because you are subscribed to the Google Groups "ClojureScript" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/clojurescript.
