This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-02-12
Channels
- # aatree (9)
- # admin-announcements (2)
- # alda (4)
- # announcements (2)
- # beginners (87)
- # boot (218)
- # braid-chat (14)
- # cbus (2)
- # cider (19)
- # cljs-dev (17)
- # cljsjs (1)
- # cljsrn (5)
- # clojure (84)
- # clojure-android (1)
- # clojure-czech (8)
- # clojure-ireland (3)
- # clojure-madison (20)
- # clojure-poland (22)
- # clojure-russia (54)
- # clojure-sanfrancisco (1)
- # clojurescript (81)
- # clojurewest (4)
- # community-development (94)
- # conf-proposals (5)
- # core-async (199)
- # css (3)
- # cursive (68)
- # datavis (2)
- # datomic (23)
- # dysphemism (138)
- # editors (7)
- # hoplon (8)
- # jobs (8)
- # jobs-discuss (7)
- # ldnclj (2)
- # liberator (6)
- # off-topic (32)
- # om (200)
- # omnext (2)
- # onyx (88)
- # proton (58)
- # re-frame (14)
- # reagent (1)
- # ring-swagger (26)
- # yada (14)
update: I was using a custom merge function, removing it made the merge more reasonable, but now it merges the [:category _]
as part of the :menu
, and the parser is unable to read because when the read reaches that point it tries to go to the root, which doesn't have the :categories
key
Maybe I have to update some tokens somewhere, so it recognises componentDidUpdate etc...?
Perhaps, by good fortune, someone already has such a file for om
@danielstockton: using clojure-mode?
yeah anmonteiro
I have a solution for you
(setq clojure-indent-style :always-indent)
add this to your init files
thanks, i'll try
@danielstockton: here are the supported options: https://github.com/clojure-emacs/clojure-mode#indentation-of-function-forms
actually, toggling the indentation had the same effect: https://github.com/syl20bnr/spacemacs/tree/master/layers/%2Blang/clojure#toggles
im not very good with emacs, i use spacemacs and pretend it's vim
seemed like i had the clojure-mode default indentation mode off, turning it on seems to work
the reverse of what is suggested in those docs
anyway, thanks a lot, led me there in the end
hmm, the indentation i was going for was actually more like :align-arguments as seen here:
https://github.com/jdubie/om-next-router-example/blob/master/src/om_router/core.cljs#L107
unfortunately, if i set it to :align-arguments, it will go back to indenting (query and (componentWillUpdate
not sure if i can achieve that, always-ident is a good compromise
@danielstockton: wow, i never knew about C-c SPC, I was doing alignment by hand, thanks!
@pyr: I just select the region I want to indent and use C-M-\
how do i turn that on, (setq lojure-align-forms-automatically true) ?
@danielstockton: (setq clojure-align-forms-automatically t)
thanks, worked 👍
hi, does anyone have a nice resource on stylying om components?
cljs.user=> (:query (om/process-roots `[{:not-be-included [^:query-root ({:this-one-goes [:yumy]} {:param :one})]}]))
[({:this-one-goes [:yumy]} {:param :one})]
metadata needs to be out of the parentheses
thnx @anmonteiro figuring out a way to prove. In my case I have a composition of query and query-root is being ruled out somehow.
@thiagofm: I'd use d/transact!
instead of update-in, personally, and I'd probably have one function to find the eid and value for :lambdas/total, and then use the output from that function to build the transact! call
@thiagofelix: So something like the snippet above
I've been going through @tony.kay 's om-tutorial (thanks, Tony!). I'm having a bit of trouble understanding queries.
Here's a gist of what I'm trying to figure out: https://gist.github.com/grzm/3d17f353224ce329855f
I’m having the behavior that the indexer won’t index a component if its query is not … not sure the right word, but like, one level away
(query [_]
[{:panes [{:quote (om/get-query QuoteRoot)}
{:calculator (om/get-query CalculatorRoot)}]}])
(query [_] `[{:panes [{:quote ~(om/get-query QuoteRoot)} {:calculator ~(om/get-query CalculatorRoot)}]}])
I think the quoting is fine … the queries run okay, props get set, things render, but the components aren’t indexed … I’m thinking that is the current design
anyone have tips on forcing lein / figwheel to pick up a new om I locally install? … it does it sometimes, but I’m not sure a gang busters way to make it always work
yah, okay, so the indexer just isn’t meant to work with queries like that, I need to put an intermediate component in there it seems
@anmonteiro: if you are up for it, I do have a question if changing indentation here, moving it under (when class)
is desired https://github.com/omcljs/om/commit/d9223a145eddfc4f66f0391d456543a3e73b654d#diff-7e4043f05bbd8e76d2da4614c2566cfaR949
@hueyp: indentation seems fine to me, what's wrong?
:sections
does not have a class so the indexer stops … previously it would still do the indexing even if no class
@hueyp: index-root
is called with a component as argument
the class should always be there?
moving the check under when class
is exactly what prevents the stack from being blown
right
so it starts off with a class, the root, and then it calls it a second time with the class being the meta :component from :sections … which is nil
do you have a failing case?
I'm happy to figure it out
20 line should be ok
(let [db {:obs [{:id 1 :name "bar"}
{:id 2 :name "baz"}]}]
(om/db->tree [{:obs [:id]}] db db))
;; result: {:obs [{} {}]}
;; desired: {:obs [{:id 1} {:id 2}]}
@hueyp: huh. well, that explains it. Is there an open issue or some other reference where I can read more about it?
@grzm: db->tree
works on normalized data
your data is not normalized
@geraldodev: that's expected. move-roots
's (a process-roots
helper) docstring says: Does NOT support sub-roots.
I’m checking the indexer directly, but you get failing cases for anything that calls full-query
on section one
all good, let me have a look
no priority from me, I’m just testing things out to see how it works, and thought this behavior might be unexpected since it is a change from alpha-30 to master
@hueyp: you were right, that's a bug
I'll submit a fix
I'm using om next. I want to run a om/transact! every 1 second(using js/setInterval), where would this logic fit?
Also, I remember seeing somewhere a long time ago, that it's possible to limit the rate that the whole frontent data gets updated(lets say, every 1s), like FPS mechanics, anybody knows hows this applies to om next? I can't seem to find any resource about it too.
By frontend data I mean not backend <-> frontend, but actually refreshing the UI(imagine I have a counter and I just want to display it's current value every 1s)
@thiagofm: override om.next/*raf*
(with caution)
Is there a tutorial that uses om next that is similar to this one for meteor https://www.meteor.com/tutorials/blaze/creating-an-app? That is, I would like one unified resource that goes through getting a full basic application to work including setting up a server and database, communicating between the server and client, rendering a view, and then syncing state between the client and the server.
@adamkowalski: there isn't one. 1) https://github.com/omcljs/om/wiki
I'm storing my state in a datascript db, and I'm having trouble getting my components to re-query/render after a transact! call
I'm not really sure what else to say about this, but if anyone has tips I'd be much obliged
@iwankaramazow: thanks, do you think that if I go through https://github.com/omcljs/om/wiki/Intermediate-Tutorial which is supposed a full stack om tutorial, most of those concepts will transfer over to om next?
@adamkowalski: Probably not. I can't really comment on this I never used Om Now.
@adamkowalski: for project setup you could probably start with https://github.com/plexus/chestnut https://github.com/anmonteiro/aemette
Thanks for the tip, but I have tried chestnut before and while it is a great project I would really like to understand what is happening with all the wiring
otherwise I feel like I will only have a crude high level overview of how to make such a project, and when I need to do something slightly different I will be unpreparred
Ideally I would find something that walks through what are the bare essentials to get an application working and how to make such a project completely from scratch so you understand how every component relates to each other
If you want the bare essentials https://github.com/omcljs/om/wiki/Quick-Start-%28om.next%29 sets you up quite nicely
My two cents on: you're probably better off studying all aspects of every tutorial in isolation, before going full stack
yeah good idea.
I am currently running through the https://github.com/awkay/om-tutorial and it seems like a really good follow up to the basic guide on the om next wiki
Hi everybody! I’m trying to use the react-motion package from cljsjs in an Om project, but I’ve never used cljsjs before and I’m having some trouble. Does anyone know how this works/if there’s a good resource I could read up on?
@adamkowalski: after the tutorial, just find yourself a side-project you can overengineer with all aspects of om next 😉
Yeah I actually made a replica of the ios calculator but I probably butchered the code haha
do you mind critiquing my code and telling me if I followed decent practices for making a basic om next app? https://github.com/adam-r-kowalski/calculator
@futuro: I think you need to pass the query related to it after the transaction... such as (om/transact! this `[('quit-tutorial {:db/id id}) :game/tutorial])
@hueyp: just submitted a PR that should fix your issue (https://github.com/omcljs/om/pull/614/)
you're welcome to tests against my branch to see if your problems go away: (https://github.com/anmonteiro/om/tree/om-612)
So, my question again. Let's say I have a setInterval every 1 second that runs a transaction, where does this logic goes to? A component? core.cljs?
@anmonteiro perhaps. Sadly I see no examples of this, even when searching on Google 😞 If I find out how, I promise I'll write a blogpost about it
@thiagofm: The official React docs suggest putting it in the lifecycle method componentDidMount
Don't forget to clean up the timer in componentWillUnmount
@thiagofm: ^ should work
Hi, I was wondering if anyone is aware of more extensive documentation I may be missing on how to use cljsjs packages. I’m trying to use the react-motion package in an om next project, and I’m… at a loss.
@adampash: Om uses CLJSJS packages
have a look here: https://github.com/omcljs/om/blob/master/project.clj#L15-L16 and here: https://github.com/omcljs/om/blob/master/src/main/om/dom.cljs#L4-L5
that's all you need
@thiagofm: earlier you asked about running a om/transact every 1 second using setInterval
i made a quick mock up of how you could do it http://pastebin.com/rPbK1YVj
thanks @anmonteiro! I’ll give it a look
@adamkowalski: oh true, I can just talk with the reconciler!
indeed, you might want to turn logger off though if you are going to do something every seconds
otherwise your console will get flooded pretty quick
Is there a way to access the reconciler down the stack/not in core.cljs(or in a separate component?). I also can't seem to be able to pass it down in (om/add-root! reconciler window/Window (gdom/getElement "app"))
Let's say I have 2 components List and Item. I call om/add-root! with reconciler and component List. The List component has a couple of Items, how can I access the reconciler from an Item?
you could extract your reconciler into a separate file (or namespace) then every other ns that needs to reference it can just require it at the top of the file
oh well it that case you are inside of the reconciler
you can do (om/transact! this ‘[(action-to-dispatch)]
you are inside off a component*
or if you have some really fancy needs you could probably use core.async and pass around a channel
then you can put actions on the channel
and on the receiving end (somewhere you have access to the reconciler) you can perform the transact
adamkowalski: when I try to do it inside a component, I keep getting No queries exist for component path (...)
can you make a minimal reproducible repo and post it here? then maybe somebody can take a look and figure out what the issue is
because if I remember correctly David Nolen said in one of his videos that visible asynchrony is not good, so i’m guessing core async shouldn’t be needed unless you are doing something non trivial
So, what I want to do is: when my component GameWindow is loaded, I want to start adding every second a number to a counter(in case, it's the player's amount of gold)
you can also (om/get-reconciler this)
from inside a component … its private I think but works
@thiagofm: in your sub component (you said you are going from a list to item) do you actually have access to this?
you could make each item take this as on of the parameters
I know of at least one use that breaks the full-query
path … if you can post your queries it would be easy to see
then you could do (om/transact! this ‘[(my-action)])
(defn my-item [this param-2 param-3] … (om/transact! this ‘[(my-action {:key my-optional-payload})]) … )
alright I gotta head out, but good luck with your project
Example: https://github.com/thiagofm/haxlife/blob/master/src/cljs/haxlife/components/window.cljs in the GameWindow component, whenever it's loaded, I want to start that count. The query is already implemented here: https://github.com/thiagofm/haxlife/blob/master/src/cljs/haxlife/data/query.cljs#L31
@anmonteiro I have a [{:current-view [{:nested-query [:stuff]}]}] query shape, and I'm using normalize true with the data normalized. Is that a sub-root ? I'm asking because to my understanding :current-view is a root and :nested-query is a sub-root. And in this case process-roots is working fine. In fact it's the composition of :nested-query via om/get-query that is wiping ^:query-root when using [{:current-view [^:query-root ({:nested-query [:stuff]} {:a-param :one})]}]
Uh, I think this is a bug (or perhaps I'm using om next in the wrong way). https://github.com/thiagofm/haxlife/blob/master/src/cljs/haxlife/components/window.cljs#L25 in this line, I'm transacting, but om keeps complaining that "No queries exist for component path", the thing is, I don't really need to query anything there, just run that transaction(which isn't dependable on anything).
This works as expected if I do any change in this file and save it, the counter goes up as I expected. But it keeps giving me the "No queries exist for component path" message
I can also change it in order to have a query so it stops complaining, I guess... The first time it complains, it stops execution. Maybe it should just warn that message.
@thiagofm: try to transact using (om/transact (om/get-reconciler this) ...)
, I think that way you will avoid the warning by calling it directly on the reconciler
I'm up to a point where everything works, but I still keep getting the error 😞 I'll go ith get-reconciler
@wilkerlucio: okay, no more messages, works perfectly, thanks!
Your tutorial ui component doesn't have a query.
You could pass transact through to GameWindow or Tutorial components using om/computed, something like (om/computed props {:transact #(om/transact! this %)}.
, then in the the children, call (:transact (om/get-computed this))
@taylor.sando: funny thing is, in the Tutorial component, it doesn't complain about anything 😛