On Monday, June 23, 2014 3:13:26 AM UTC-4, David Della Costa wrote: > Leaving aside the irrelevant details of creating an absolutely > > positioned widget of some sort, here's how I would create a component > > which keeps track of window resizing events. It's very simple and > > doesn't require anything other than default local state: > > > > https://github.com/ddellacosta/om-resize-listener/blob/master/src/om_resize_listener/core.cljs > > > > I didn't bother to add IWillUnmount for un-listening to resizes, but > > obviously that's no big deal to add. > > > > DD > > > > (2014/06/23 12:36), Mike Thompson wrote: > > > On Monday, June 23, 2014 1:10:39 PM UTC+10, Mike Thompson wrote: > > >> On Monday, June 23, 2014 11:59:45 AM UTC+10, David Della Costa wrote: > > >>>> itself in the right absolute position if the window resizes). Its > > >>> > > >>>> not that you can't do this in OM, of course, but, as I understand it, > > >>> > > >>>> you'd have to merge the window dimensions into the main atom, and > > >>> > > >>>> meaning the "reusable" popup component would require that every > > >>> > > >>>> app-state had these window dimensions at the same place (cursor). > > >>> > > >>>> Feels a bit hacky to me. (If I've lead you astray here, and there's > > >>> > > >>>> a better way to create such a reusable component in OM, I hope > > >>> > > >>>> someone will correct me.) > > >>> > > >>> > > >>> > > >>> Each Om component has local component state, just as in React. You > > >>> > > >>> certainly don't have to merge everything into the global app data as you > > >>> > > >>> describe, and UI concerns like this are exactly the use-case for local > > >>> > > >>> state. This is all described in the tutorials and docs. > > >>> > > >>> > > >>> > > >>> https://github.com/swannodette/om/wiki/Documentation > > >>> > > >> > > >> Yes, I've found myself crawling over those docs a few times. :-) > > >> > > >> So, if I understand you correctly ... to create a reusable, absolutely > >> positioned popup component, you are suggesting something like this: > > >> - in IDidMount, hook the window or <body> for "onresize" events > > >> - in IWillUnmount, unhook the listener on the way out. > > >> - when a resize event comes through, use "setState!". Does this > >> trigger a re-render of the component? > > > > > > Hmm. That 3rd step should use updateState! (not setState!). And I can now > > see that it does cause a re-render. > > > > > > Am I on the right track here? > > > > > > -- > > > Mike > > > > > > > > >
So that brings us back to the earlier question: is there anything Om can do that Reagent cannot? -- 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.
