This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-09-22
Channels
- # admin-announcements (5)
- # aws (32)
- # beginners (2)
- # boot (51)
- # cider (33)
- # cljs-dev (4)
- # clojure (83)
- # clojure-berlin (11)
- # clojure-czech (23)
- # clojure-poland (3)
- # clojure-russia (51)
- # clojure-seattle (4)
- # clojure-sg (1)
- # clojure-uk (4)
- # clojurescript (48)
- # clojurex (1)
- # datomic (26)
- # devcards (10)
- # devops (12)
- # editors (9)
- # emacs (12)
- # events (1)
- # funcool (14)
- # hoplon (117)
- # immutant (1)
- # jobs (2)
- # ldnclj (32)
- # ldnproclodo (12)
- # om (51)
- # onyx (17)
- # reagent (11)
- # yada (4)
I bought an early version of this course and its excellent: https://twitter.com/ericnormand/status/646144572473524224
@darwin: yes, your PR is very interesting, i'm watching it from the beginning. i just have not enough time these days to try to integrate it. i will do at planned refactor next month
@darwin: and, honestly speaking, i feel that all our improvements (including applying re-frame to om, and then emulation of anonymous, lexical-scoped dbs in re-frame) are attempts to make from react/om/ragent/re-frame something, which is already partly implemented in hoplon
@ul, @darwin: These look great, I’ve been wanting to do this but now I dont have to!
I have a newbie type question about Om and how to use buttons to cause another sibling view to switch out. I was thinking I could use shared state but that seems global to the app. Is there a way to put the state in the containing component and then still get to it without passing it in all over? The page looks like: staypufd [12:36 PM] navbar across top, then buttons down side in there own div section the is 1/4 of grid, then another div for middle and right of screen. When a button is clicked on left, I want to set state and then react to that and switch out middle staypufd [12:36 PM] any help would be appreciated as I”m a noob to OM
I’ll look. I’m still not clear on the component that comes in as owner. Is that the containing component that your running build or build-all in?
If so I’d think you could put the state there. Like current-button-selected and then b/c your two sections (divs) both are children they’d be able to access that
you write code that is delegated to for specific operations like rendering or lifecycle
you should read up on component local state in React and refer to the signatures provided in Om
I guess the simplified version of my situation is you have two sibling views, one with buttons that when clicked you want to have the other sibling view switch out it’s content
Y - but I’m not sure how the sibling can write to one anothers data yet, b/c as you mentioned I don’t have a good understanding of how the data is structured and who can do what
"For communication between two components that don't have a parent-child relationship, you can set up your own global event system. Subscribe to events in componentDidMount(), unsubscribe in componentWillUnmount(), and call setState() when you receive an event. Flux pattern is one of the possible ways to arrange this."
@staypufd: The easiest option as @dnolen mentioned would be to pass a callback to the child component that is triggering the action. You can pass it as :opts in the map argument to om/build. The callback would simply do a set-state using the parent’s owner (or “component” in ur case) and the value from the child, causing a rerender on the parent. then your get-state should work as-is. If its still unclear i’ll update your gist with some sample code
OK - I updated the gist with the functions that show the buttons creation. One function with list of button names calls another to actually build the buttons. I’m assuming the callback would need to be passed in the :opts of those as well?
I’ve been stuck on this for a couple of days b/c I haven’t been understanding how to do this
In my function right now for section-button-view I have it trying to set state on the owner, but that owner is not the same as the one with the component state so it seems from what your telling me that the :on-click I have in section-button-view will pull the callback out of the opts that’s passed in and call it instead
yes, so if you define the function in the parent and pass it to the child, the owner would be scoped to the parent. See this example: https://github.com/omcljs/om/blob/245d5b0a5837593e412f31c1eb2ac376b8ffa7b7/examples/state_bug/src/core.cljs#L26