Questions tagged [om]

A ClojureScript interface to Facebook's React.

om allows their users to represent data as Extensible Data Notation (EDN).


Documentation

138 questions
4
votes
1 answer

OM: deref cursors in event handlers?

I'm trying to understand when we must deref a cursor to get its value. In the om cursors wiki it states that event handlers are considered not part of the render phase, and therefore cursors in handlers should be drefed. Same is shown in the…
Asher
  • 1,019
  • 9
  • 22
4
votes
2 answers

How to create Material UI component in Om Clojurescript?

First of all, this https://github.com/taylorSando/om-material-ui doesn't work with latest React/Material UI. The main reason, I think, is this warning in console: Warning: Something is calling a React component directly. Use a factory or JSX…
ma2s
  • 1,202
  • 1
  • 8
  • 20
4
votes
2 answers

How can I write write reloadable async code with Om + Figwheel + core.async?

I would like to write something like a clock app. The state is basically a number which is repeatedly incremented. One way of doing it can be seen here. (ns chest-example.core (:require [om.core :as om :include-macros true] [om.dom :as…
4
votes
1 answer

Is it possible to reuse existing React components in ClojureScript Om app?

I have a lot of React components in my current project. Is it any way to reuse this components, if I decide to write next project in Om?
azaviruha
  • 807
  • 1
  • 7
  • 14
4
votes
2 answers

Passing App Atom vs Ref-Cursors in Om

Using Om, it seems like passing relevant parts of the app state to child components is effectively the same thing as not passing any app state but using ref-cursors. What is the use case for ref-cursors over passing pieces of the app state down the…
user3594595
4
votes
1 answer

How to loop a JavaScript object and push each into an array, in Clojurescript

How can I convert this function (into Clojurescript) that takes a JavaScript object and pushes it's contents into an array. function toKeyValueList(obj) { var arr = []; for (var key in obj) { if (obj.hasOwnProperty(key)) { arr.push({ …
Henry Zhu
  • 3,443
  • 5
  • 24
  • 36
4
votes
2 answers

Is there any way to make an onClick handler in Om without using anonymous function?

I want to make a click handler function for an Om component. The docs and Stack Overflow examples I've found always declare anonymous functions like this (defn main-view [_ owner] (reify om/IRender (render [_] (let [xs (items)] …
lk145
  • 1,307
  • 2
  • 13
  • 17
4
votes
1 answer

React's Refs in Reagent (or Om)?

I sometimes find it useful to use React's Refs in order to change the state of the DOM as for example to focus an input field after rendering a component. Does Reagent or Om implement this or if not what is the idiomatic way to do this in those…
kliron
  • 3,895
  • 3
  • 28
  • 43
4
votes
2 answers

Om app-state and application structure

I'm displaying a menu in Om, using a component and subcomponent like this: (def app-state (atom {:location "" :menuitems [["Pages" "/pages/"] ["Images" "/images/"]]})) (defn menu-item-view…
Drewes
  • 2,061
  • 1
  • 16
  • 16
4
votes
1 answer

Om callback after render (to focus an element after changing application state)

I have an text input element that uses component state and application state. In the example shown in React: More About Refs, the goal is to call focus on the element after re-rendering. Here is the key part, done with JS in…
David J.
  • 28,507
  • 20
  • 108
  • 162
4
votes
1 answer

Consequences of not closing channels in browser?

I'm using Om for the client side and through the lifetime of the application many components gets mounted/unmounted. When mounted, various channels are opened (in go blocks). And I'm planning to use IWillUnmount to close them too. But first, my…
roboli
  • 1,220
  • 16
  • 24
4
votes
2 answers

What should an om component return to render nothing?

Is it possible to write a component that renders nothing, for example, if its cursor data is empty ? I can not do (defn count-or-nothing [list-cursor owner] (reify om/IRender (render [_] (if (not (empty? list-cursor)) …
phtrivier
  • 12,156
  • 4
  • 42
  • 73
4
votes
1 answer

Unable to display two components in OM

I am attempting to learn Om, and have come across something I don't understand. I would expect this code (defn search-page-view [app owner] (reify om/IRender (render [_] (dom/div #js {:id "search-block"} "Test") …
oneway
  • 713
  • 1
  • 5
  • 9
4
votes
3 answers

What does this "#" mean in this Clojure context?

I stumbled upon the official Om example under "examples/mixins", there's a definition as this: (def MyComponent (let [obj (om/specify-state-methods! (clj->js om/pure-methods))] (aset obj "mixins" #js [TestMixin]) (js/React.createClass…
Minos Niu
  • 85
  • 6
4
votes
1 answer

Editing Om input properly with set :value

I need to display an input element with an initial value read from a cursor, but I don't need to update the cursor back when the user enters the new text. For example: (defn my-comp [app owner] (reify om/IRender (render [_] (dom/div…
roboli
  • 1,220
  • 16
  • 24
1 2
3
9 10