This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-12-02
Channels
- # admin-announcements (29)
- # aws (11)
- # beginners (247)
- # boot (11)
- # business (1)
- # cider (73)
- # clara (5)
- # cljs-dev (37)
- # cljsrn (29)
- # clojure (86)
- # clojure-dev (9)
- # clojure-indonesia (1)
- # clojure-italy (3)
- # clojure-nl (1)
- # clojure-russia (195)
- # clojure-sg (2)
- # clojure-uk (3)
- # clojurecup (1)
- # clojurescript (296)
- # clojurex (2)
- # code-reviews (6)
- # core-async (3)
- # cursive (33)
- # datavis (9)
- # datomic (11)
- # funcool (31)
- # hoplon (1)
- # ldnclj (8)
- # lein-figwheel (5)
- # leiningen (5)
- # luminus (4)
- # off-topic (3)
- # om (172)
- # onyx (13)
- # re-frame (5)
- # reagent (84)
just wondering if anyone else has a clean solution for serializing and/or cleaning the results of remote mutations, since the new :result
key may include things that transit doesn’t know how to serialize (in our case this is a bunch of Datomic tx info)
@joshfrench: it’s trivial to elide, just elide it
@dnolen: I’m stripping it at the server layer, is it possible to do the same from within the parser itself?
@eguneys: yes, the parser impl in om.next.server is for parsing on the server. :value
on the server I believe doesn’t do anything (except for tempids but dont worry about it) except to give a clue to developers about which keys might have changes as a result of the mutation
I also think that is an old style for the :value result. I think the new style is supposed to be a map.
@joshfrench: I could imagine putting the behavior behind a flag, we can look at later when the more pressing things are sorted out
@eguneys: and about remotes, in @dnolen's example the default read wouldn’t refetch the key automatically. Usually if you caused the change on the client with a transaction you would include the key to be read afterward in the transaction. If the server changed because some other user did something for example you would need a way to push data to the client to tell it to read (for example with websockets or long-polling).
I'm using DataScript. Rendering data as a table. The query and component structure from the root is as below: {:app {:table [{:table-row [...]} {:table-row [...]}] }} I have it setup so I can click on an element in a row and modify the text. The mutate works, the DataScript db is updated. But when the render method of the row is called, it is called with the full props all the way from the root i.e. all of the below: {:app {:table [{:table-row [...]} {:table-row [...]}] }} I was expecting it just to get the props for the row, i.e. like this: {:table-row [...]} All the rows have idents. It seems like there is a missing link between the query and the row, so Om defaults to passing props from the root. Is this right? Anyone have any pointers? Thanks!
Anyone know how I can interface om.next with a library like Chartist, which does its magic with commands like new Chartist.Line('.ct-line', data)
? Is there some way to execute code after a part of the DOM has already been rendered?
Do you have suggestions for other chart libraries that may behave better?
not saying you cannot use Chartist...just that your idea about how to integrate needs to be careful
remember that react wants to own the DOM, and Om tries to manage the app state and re-rendering
I'll do that; thanks.
Does anyone know how to add a list item(person) for this tutorial? https://github.com/omcljs/om/wiki/Components%2C-Identity-%26-Normalization
I added a button for RootView and a mutate function.
(defui RootView
static om/IQuery
(query [this]
(let [subquery (om/get-query Person)]
`[{:list/one ~subquery} {:list/two ~subquery}]))
Object
(render [this]
(println "Render RootView")
(let [{:keys [list/one list/two]} (om/props this)]
(apply dom/div nil
[;; add --------------------------------------------------------
(dom/button #js {:onClick
(fn [e]
(om/transact! this `[(list/add)]))} "add")
;; ------------------------------------------------------------
(dom/h2 nil "List A")
(list-view one)
(dom/h2 nil "List B")
(list-view two)]))))
(defmethod mutate 'list/add
[{:keys [state]} _ _]
(let [name "Mike"
new-person {:name name :points 0}]
{:action
(fn []
(swap! state update :person/by-name assoc name new-person)
(swap! state update :list/one conj [:person/by-name name]))}))
When I clicked the button, mutate function is called, but view is not changed. I want to know correct action code to add a person for :list/one.
transact! accept the list of dependent keys that has to be re-read after the mutation, maybe this is a case for that
Do I have to implement migrate to update tempids from the server?
(datascript)
Just want to make sure I'm on the right track
Bonus points if anyone has this stuff already figured out with datascript. I'm not datomic/datascript expert, curious if my implementations are 'correct'
my merge-tree looks like :merge-tree (fn [_ data] (doseq [t (vals data)] (d/transact! conn t)) @conn)
@snufkon: You shouldn’t need to do anything else…render will occur as you are transacting from root. Your add person will only work once though due to same identity being created. I have created a gist with a working version. Well works for me! So it must be something else in your code that you didn’t post. https://gist.github.com/griffio/87e3ff9f88d9d8fbc7a5
is there a way to use om.next master in a project? I realized after alpha24 David might be aiming for beta 1 and not releasing any more alphas?
@txus I think it was mentioned somewhere but clone the om repo and and then lein install. Add 1.0.0-alpha25-SNAPSHOT to your project deps. If that is what you need to get the latest cut.
@txus don’t forget to do a clean or delete of your js build when upgrading versions 😭
@griffio: both your and my code didn't work. But after I upgrade om and clojurescript versions both works!
;; not work
[org.clojure/clojurescript "1.7.170"]
[org.omcljs/om "1.0.0-alpha22"]
;; work
[org.clojure/clojurescript "1.7.189"]
[org.omcljs/om "1.0.0-alpha24"]
Everyone is using atoms over datascript? Wonder why, seeing as although they're easier to understand initially, when you have to introduce all the db->tree and tree->db stuff, they're no longer just atoms.
@danielstockton: no people are using DataScript but some things are less obvious with DataScript
And there doesn't seem to be a good story for using other remotes than datomic yet, anyone tried?
@danielstockton: this is incorrect
Seems atoms may also be easier if you're getting json back from a remote
I know but there is more to implement on your own with other backends and i haven't seen any attempts yet
Not saying it's difficult, it just isn't the easiest route to 'having something', which is where most people probably are at the moment (experimenting)
people will figure it out eventually and I doubt it will be much more work over plugging in Datomic
Did I figure out correctly, that implementing a custom migrate is what's needed to update tempids in the datascript case?
Do you think there are advantages to using atoms other than they're easier to understand for newcomers?
looking forward to somebody spending a long weekend coming up with a simple acceptable solution for SQL stores
I wonder why you didn't push datascript more, I have a feeling that the query syntax and easy integration with datomic will bring a lot of new people to using datomic (i seem to be one of them)
@danielstockton: because I don’t care about DataScript or Datomic
@danielstockton: yes someone will need to sort through a standard way for dealing with tempid transition in DataScript
similarly the link feature, but I wrote up a quick prototype with with-db
and it seems to work fine
I understand it's not relevant to the design but you could have gone with a different 'default'
Fair point, I guess i'm thinking that a lot of the normalization stuff could have been omitted and then it's more natural fit than being integrated
The normalization stuff didn't need to be core to om, you could have told people that the store needs to be normalized and left it to them
Anyone using datascript can give some high level pointers on how things can work? I'm not sure how to 'update' the tempid on the client? Or should I generate a 'real id' in advance that get's sent to the remote?
I suppose I could bypass this problem by losing optimistic updates..
Only transact on the client once receiving things from the server...
@danielstockton: or use lookup refs, DataScript supports those
Aha, thanks for the tip. This looks like it matches very closely the idea of idents in om
I sometimes feel confused between ident and lookup ref, in datomic it seems that ident is just the keyword part of a lookup ref
In om, do we call them lookup refs or idents? Or what is the clear separation
ok, understood
so merge-refs is more like merge-idents, or the two terms are interchangeable in om land
@danielstockton: FWIW I experimented a bit with om.next and rethinkdb, and the two were a pretty great fit. The syntax for “plucking” in rethinkdb is basically the datomic/om.next pull syntax
@danielstockton: fixed in master thanks for pointing that out
@chris-andrews: that’s cool to hear!
@danielstockton: the only place where ref is should be used outside of React ref terminology is ref->any
and ref->components
ok, glad my questions actually help create some clarity
good to know @chris-andrews, thanks
I have a RootView component, and a couple of nested components. When transacting a delete from one of the nested components (deleting a record from :app/users), @reconciler
seems to have all the expected data after the delete, no problem, but RootView, which is querying it, it gets all the props EXCEPT that :app/users
is an empty seq
the whole point of parsing being an a l carte thing is you can test data consistency issues via normal REPL evaluation and normal tests
the only thing that I can think of is maybe I’m messing with the data tree in the mutate and after that the read no longer works
once you seen that transduction with a vector is nearly as fast as a for loop over a mutable array
@txus in case you didn't know, some things have vector equivalents mapv, filterv ...
i end up using them a lot in cases like this
so it may be only 1 more letter
@danielstockton: those things are less useful now that into
takes transducers and generalizes those
yeah, i haven't quite grasped the power of transducers yet
@danielstockton: oh I didn’t know! Thank you
@dnolen: for a single seq / vector pass, into + transducers is still the same as th usual seq / vector operations on their own right?
also, just in case, does what you mentioned about only maps / vectors in Om apply to sets?
txus, think it needs to be associative so that it can know what to rerender
so that rules out sets too
I don’t see any compelling need for sets … could be persuaded but would have demonstrate something that isn’t just about convenience
just saw this tweet from @dnolen https://twitter.com/swannodette/status/672087958309224449
Hi Pierre-Yves !
I know it's not perfect to shoot for REST but in plenty of cases it would provide a good transition path
I’d imagine you might make a specific remote for each REST endpoint, and in your send function have different implementations for each one. The endpoint specific code would then take the Om query, translate it into api params for the REST endpoint, hit the endpoint, then translate the response data into something that can be merged into your app state and call the callback passed to send with the transformed data.
nice, @pyr the link is https://github.com/omcljs/om/wiki/Remote-Synchronization-Tutorial
I'm reworking the sections on app database and queries in om-tutorial. I'd appreciate feedback if anyone has time to look it over. Note the instructions for startup may have changed. Check the README. https://github.com/awkay/om-tutorial
C_App_Database_Exercises.cljs?
I’ll have a look
@artemyarulin: thanks that and queries...the queries part now has interactive cards for running queries against a real db...I think it is a lot more effective
@tmtwd: yes you can access and set the local state in Om.Now
@tmtwd: of course, this is not an Om feature, this is React’s feature. It is well explained on their site
@tmtwd: you are welcome
Hey ! I wonder what is a purpose of path
in the env
passed to read/mutate functions. Seems like it's always []
.
@dnolen: you wrote that you made a quick prototype (with-db)
for making links work with datascript's :db/id
. Is this online anywhere we can see it?
the schema relationship as in the datascript schema? so something like: :some/refs {:db/valueType :db.type/ref :db/cardinality :db.cardinality/many}
? And rather than populate the :some/refs
field with a vector of ids, compute a vector of om links dynamically and query that?