ANN: Om 0.8.0-alpha1, Reference Cursors!

399 views
Skip to first unread message

David Nolen

unread,
Oct 18, 2014, 11:53:50 AM10/18/14
to clojure, clojur...@googlegroups.com
I'm happy to announce the release of Om 0.8.0-alpha1. This release
includes the single biggest conceptual enhancement since its initial
release - Reference Cursors.

As we begin to build larger and larger applications with Om, we
often run afoul of the need to organize our application around a
hierarchical tree. This is more problematic than in React itself as Om
emphasizes a programming model that supports full snapshotting of the
application state. This seemingly beneficial property actually
exacerbates the hierachical issue and often leads to an incredible
amount non-modular programming!

The introduction of Reference Cursors allow Om programmers to stop
thinking in terms of trees and return to a more natural mode of UI
programming - simply calling out into shared APIs around application
data precisely where you need it. No need to pass data through
intermediate components on way to the target child component -
Reference Cursors allow you to get at the data exactly where it is
required and this without abandoning the ability to time travel over
your application state.

There are more thoughts and details here:
https://github.com/swannodette/om/wiki/Advanced-Tutorial#reference-cursors

Please give Reference Cursors a try in your application and send lots
of feedback!

This is an alpha release. No previous Om APIs should be affected,
however the Reference Cursor feature is largely untested beyond
a simple example in the repo.

https://github.com/swannodette/om

Cheers,
David

Dave Della Costa

unread,
Oct 18, 2014, 12:17:24 PM10/18/14
to clojur...@googlegroups.com
This is a great move, and I think exactly right--it addresses my main
frustration when developing at scale with Om. I look forward to testing
this out and will definitely be giving feedback. Kudos, David.

DD

Daniel Kersten

unread,
Oct 18, 2014, 12:20:23 PM10/18/14
to clojur...@googlegroups.com, clojure
Fantastic work, David! Thank you for all your hard work on Om!

This is definitely an exciting release and I look forward to playing with it over the coming days. I'll be sure to report back on my experience with it.


--
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 clojurescrip...@googlegroups.com.
To post to this group, send email to clojur...@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.

Gary Trakhman

unread,
Oct 18, 2014, 12:21:23 PM10/18/14
to clojur...@googlegroups.com
Is this analagous to facebook's cursor.cursor(subPath) method?


David Nolen

unread,
Oct 18, 2014, 12:40:22 PM10/18/14
to clojur...@googlegroups.com
No, getting sub cursors from cursors has been supported since cursors
were first introduced.

Gary Trakhman

unread,
Oct 18, 2014, 12:47:35 PM10/18/14
to clojur...@googlegroups.com
I think before, you could only grab a subcursor in the render method.  In the facebook impl, I think you end up with a subreference that you can then deref at any time.

David Nolen

unread,
Oct 18, 2014, 12:53:23 PM10/18/14
to clojur...@googlegroups.com
In anycase - no, this isn't related in anyway whatsoever to reference cursors :)

David

Gary Trakhman

unread,
Oct 18, 2014, 12:55:58 PM10/18/14
to clojur...@googlegroups.com
I think I understand the difference now, there's no notion of a render-phase there, we have one in Om and it interacts conceptually with these references.

Thanks (I hope I understand it right :)

Mike Haney

unread,
Oct 18, 2014, 1:19:53 PM10/18/14
to clojur...@googlegroups.com
Quick question - does om/ref-cursor only take a cursor as input (as shown in the tutorial), or can it take any value? For example, can I compute a value based on different parts of the app state and then create a ref cursor from that? If so, what are the consistency guaranties, i.e. is the ref cursor updated when the data it depends on changes?

David Nolen

unread,
Oct 18, 2014, 1:30:35 PM10/18/14
to clojur...@googlegroups.com
For now you create ref cursors via root-cursor. Making a composite cursor is not needed. Just observe several ref cursors.

It should be impossible to see an inconsistent state, rendering has been changed to efficiently account for ref cursors.

On Saturday, October 18, 2014, Mike Haney <txmik...@gmail.com> wrote:
Quick question - does om/ref-cursor only take a cursor as input (as shown in the tutorial), or can it take any value?  For example, can I compute a value based on different parts of the app state and then create a ref cursor from that?  If so, what are the consistency guaranties, i.e. is the ref cursor updated when the data it depends on changes?

Mike Haney

unread,
Oct 18, 2014, 1:32:23 PM10/18/14
to clojur...@googlegroups.com
That makes sense, thanks.

Sean Grove

unread,
Oct 18, 2014, 2:21:26 PM10/18/14
to clojur...@googlegroups.com
I'm looking forward to playing with it as well. Definitely seems like a thoughtful experiment - thanks David.

Ahmad Hammad

unread,
Oct 18, 2014, 7:44:06 PM10/18/14
to clo...@googlegroups.com, clojur...@googlegroups.com
Brilliant! Looking forward to digging into it. 

P.S I was wondering when that Advanced tutorial was going to be written, looks like its up!

Don't know how you find the time but glad that you do!

Jonas Enlund

unread,
Oct 19, 2014, 1:38:00 AM10/19/14
to clojur...@googlegroups.com, clo...@googlegroups.com
Hi

Interesting work as usual! One quick question: What is the difference between

(let [xs (om/observe owner (items))]
...)

as seen in the sub-view component versus the one in main-view which doesn't use `om/observe`:

(let [xs (items)]
...)


/Jonas

David Nolen

unread,
Oct 19, 2014, 1:52:06 AM10/19/14
to clojur...@googlegroups.com
The parent view doesn't depend on items - that is, it does not need to
re-render if items changes.

David

Todd Berman

unread,
Oct 22, 2014, 3:42:23 PM10/22/14
to clojur...@googlegroups.com
I have been experimenting with reference cursors (which are great!), however I am running into a weird issue.

It appears that changes made to a ref-cursor don't cause tx-listen to fire.

Is that expected?

--Todd

David Nolen

unread,
Oct 22, 2014, 5:35:31 PM10/22/14
to clojur...@googlegroups.com
Expected for now. I'm beginning to rethink the role of :tx-listen -
it's perhaps more useful as a simple pattern that we describe rather
than an official part of the API.

In anycase, I'd like to push ref cursors a bit further and see how
people use ref cursors in their experiments before making any
decisions.

David

Todd Berman

unread,
Oct 22, 2014, 5:49:05 PM10/22/14
to clojur...@googlegroups.com
That makes sense to me.

Given that, if I was using tx-listen, is it best to just switch over to add-watch on the root atom itself and serialize changes to the server from that?



You received this message because you are subscribed to a topic in the Google Groups "ClojureScript" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/clojurescript/I8-kYj-eKBs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to clojurescrip...@googlegroups.com.

David Nolen

unread,
Oct 23, 2014, 12:57:05 AM10/23/14
to clojur...@googlegroups.com
Yes that's one way. There's other possibilities but I want to think it through before suggesting anything specific.
Reply all
Reply to author
Forward
0 new messages