This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-02-27
Channels
- # beginners (106)
- # boot (124)
- # cider (11)
- # clojure (105)
- # clojure-poland (2)
- # clojure-russia (28)
- # clojurescript (89)
- # core-async (14)
- # cursive (10)
- # datomic (7)
- # emacs (12)
- # garden (5)
- # hoplon (345)
- # immutant (127)
- # mount (2)
- # off-topic (24)
- # om (24)
- # onyx (8)
- # parinfer (51)
- # proton (2)
- # slack-help (4)
- # spacemacs (1)
@numberq: server errors also happen if your server isn't running properly. Have you tried a REPL and evaluated your whole API? Usually that tells me that my database initialization went wrong.
if I have (defc foo 1)
is there any way to get at the foo cell inside a cell=
, or can i only get at the value 1
?
although it then becomes very hard to reason about the program (and easy to have memory leaks)
because i have a datascript connection as a cell
and i want to pass the connection around rather than use a global connection or pass the db
having cells kind of presumes that you have a root cell somewhere with the value that gets set there
that’s what i did
that’s what the problem is
because if the value of the cell is the db
that means the cell is the connection
so if i want to work with the connection, i can’t just have the db value
like, if i want to do (d/transact! conn tx)
well no, i’m not doing that atm
but i am running queries against it
i wanted to have a consistent usage of conn
throughout the functions i wrote to wrap my queries
rather than passing a db for reads and a conn for writes
that seemed weird to me
but if i pass the conn around, i can easily write tests
using with
and make a bunch of different conn
s on the fly during the tests
I mean you can probably do it your way, only it doesn't really play well with the concept of cells
yeah, i have some complicated logic resulting in a transact!
but the actual transaction is pretty simple
so i have a test where I pass in the situation(s) that would result in a transact
then compare the conn after the change, to a fresh db using with
to get at the end-state
i might try just wrapping the conn
cell in another cell, for usage in cell=
hopefully that doesn’t break everything
(with-redefs [db/db (cell (test-db))
db/conn (new-conn)]
(logic!)
(is (= @db/db (db/with (test-db) ...)))
something like that?haha, i like to refactor
so i write tests
i’m always surprised by what i manage to break
especially when I’m sure I won’t break anything
the only reason I picked up on this issue that I’m now asking about is because of a test i wrote 😛
@dm3 maybe it’s not so bad to do db for reads and conn for writes
i think the point you make about transact!
inside cell=
is pretty much right
i do want to keep the functions that work on conn and db only working with the arguments they take
i can already see that i might want two or more different dbs to track the state of different things
so if i do that, i might also want functions that can operate equally well on the different dbs
I find that the best structure is when you have ns'es that encapsulate your state and logic fully from the views
so you have you defelems
and whatever which make calls to users/...
, orders/..
both for queries and for "transactions"
(ns cart.view
(require [cart.state :as cart]))
(defelem cart [...]
(div :click #(cart/remove! @%)
(text "~cart/status")))
something like thatyeah, i’m slowly working towards that
i think i might need one state that persists and one that doesn't
for tracking things like “keys pressed"
I have a bunch of states managing different concerns, some of them in datascript db, some in cells
i’ll try it out
but i suspect it will be good to have a “state that persists” which is basically the user’s data
and “state that tracks transient things” which is the user’s input
which would actually be bad to accidentally persist
@dm3 i got inspired by the select-id
cell from the other night 😉
i want to take this (and (not @id) (which-key/pressed? :backspace %)) (reset! select-id (-> @state:sorted last first))
from the keyup
and turn it into something that just uses the information about what was pressed from an existing cell
but I don’t want to put too much in the one PR >.<
but yeah… it helped me write some tests that i hadn’t figured out how to write previously
i didn’t know how to easily get at selected text, or the cursor position in selenium
but writing tests against the value of a cell is easy
endorsed Hoplon on HN https://news.ycombinator.com/item?id=11186983
what are Om and Reagent like
have you used them?
Reagent seems simple but you have to know there are 3 (!) forms of components that you can create
(I mean tricky as in the effect of the code on DOM is hard to reason about without knowing the implementation details)
considering i’m learning cljs as i go
glad i chose the least complicated option
i do not have a huge team
there is a lot of discovery going on, lol
but not sure how much of that is me and how much is the framework
what are the advantages of the different components in reagent?
not the advantages, you have to know that you need to use one way over the other in different contexts
like look at the last point: https://github.com/Day8/re-frame/wiki/Creating-Reagent-Components#appendix-a---lifting-the-lid-slightly and compare with what you get in Hoplon - a function that will create a DOM element. That's it.
is Hiccup a templating language?
wah, that refactor just took me 13 days to wrap up but fixed 4 tx, two of which i had no idea how to tackle otherwise, and paves the way for another 5 tx that i didn’t really know how to do either
thanks again for helping me @dm3
i’ve been trying to show people hoplon
but it’s really hard to explain to someone who doesn’t know any clj
@thedavidmeister: re: cell w/ db in it, have you considered using a lens?
it exists for the case when you want to export a cell value and also export a particular way of updating it, without exposing too much about what contributes to the cell value
@alandipert: i haven’t looked at lenses yet
i need to learn how they work first
hehe of course 😄
if you think it’s worth looking at, i’ll set aside some time to investigate
right - the lens cell can have the db update logic inside it
@dm3: thanks for the kind words on HN
hmm, so i could make a lens version of transact!
?
and just work with the db everywhere
and not worry about the conn
?
i could still listen to the conn
if i referenced it directly?
or once i make a lens-transact! i am stuck?
the particular case that lenses address are situations like these
@alandipert - someone needs to promote the work
ok, from what i read, i might need listen to get the data into something like datomic later
(def root (cell {:x 123}))
(def num (cell= (root :x)))
(defn inc! [c]
(swap! root update :x inc))
so imagine we created num
because we only want to expose :x
to some consumer, or component within our app
because the more about the structure of root
we expose, the more coupled to it dependent cells become
so num
is a "line in the sand" so to speak
yeah, for me, num
would be the query i’m running
cool
so where num
is this effort to narrow what's exposed to consumers, inc!
stands in contrast
as it takes the root cell
so the way a component would view and a way it would update are not symmetrical
that’s exactly what i ended up with
but in datascript language it is conn
for write and db
+ a query for reads
i didn’t mean to do that, it just sort of happened
i think it’s ok
i only have one query and one loop-tpl atm
so i’m kind of over-analysing 😛
i’ll let you know if something comes up that i didn’t think of
it's really awesome what you're doing btw
i'm not aware of anyone going as far w/ the datomic ideas and cells
haha, it’s only because i suck at clojure
i think i’ll find it easier to deal with a db
than mess around with raw clj data
that's still mindblowing though
building a reactive network of databases... in the browser?
i would also refute that you suck lol
ok, well let’s say that clj is my least-good language >.<
@dm3: have you used reframe btw?
and I now have a weird mix of Javelin-based state, Datascript and event-based sync with backend
what is the difference between "Reactive-Atom” and a cell?
so i’m reading https://github.com/Day8/re-frame
Hoplon gets mentioned a lot
but I don’t understand the problem that Hoplon has that this is solving?
so they picked a framework, and it made a problem
I think the implicit argument is that they "need to" use React for whatever reason
and the framework “at it’s best” is close to Hoplon
and the solution is… 20 pages of stuff
to explain
and this diagram
is that common?
perf issues in Hoplon?
I haven't, but I've heard Colin Yates complain when he added ~20k things to his app (whatever those things were)
i don’t think i’ll need 20k
is there any low hanging fruit for perf in Hoplon
or is it about as good as it will get?
@alandipert: do you have any feedback for me on https://github.com/hoplon/hoplon/issues/85?
@alandipert: happy to make changes, but i’d need some guidance to go much further than i did on the PR
@thedavidmeister: i think there is a lot of opportunity for perf improvements
not at all
actually, i keep expecting to, but i don't
i’ve had to work around race conditions that were really confusing me
but the solution was to just keep making things more abstract
until i could no longer reproduce the issue
i’m a big fan of knowing what you could optimise, but only optimising once you have a problem
that were part of the hot section
perf stuff often makes things complicated and buggy
that sounds pretty stable
to the point where the repo kind of looks abandoned 😛
like i think the priority-map implementation could perhaps be shaved a bit for perf
yeah, that’s the way all projects probably should work
but i gotta say it’s weird
ah, i found something to nitpick
you could have a cache in your travis setup
it would go like 10s faster
thedavidmeister
sweet
i should put up a PR then
actually… it’s nearly 2am
i should go >.<
catch
awesome, but i’ll still test on my account before i change anything
feel free to push changes to those repos, just things that add or change the api maybe should be done with community input
I do actually want to stick up a bunch of basic tests for hoplon
like, just checking that all the elements actually render the right HTML
on a particular branch?
aaah ok
but then how do you review the tests before rolling a new release?
you’d have to go back to the other repo each time
it was a proof of concept
yeah, i’ll look at it when i have time for sure
it’s good to get in the habit of writing tests as you find/fix bugs, at the least
even if you don’t go for comprehensive coverage, at least you know the stuff that tripped you up in the past won’t come back
awesome
we haven't had any regressions that i can remember
the way i see it, is writing 10 tests upstream saves 100 tests in my projects 😛
and browser testing stuff is tougher than just asserting data out of functions
so i’d like to know the browser stuff is rock solid from the framework, and i can just test my data in my project
yeah, it’s the right approach for that
and setup phase uses the things you're testing
i guess it depends what you’re testing
making sure that (div)
spits out a div and not a dov
that we can lock down easy
that sounds cool
you’ll have to show me how to do that
i haven’t written my own macros yet 😉
just been using regular functions
basically if you find yourself cutting and pasting code in the editor, a macro is an option
ah ok, i copy and paste data, but not code
i usually refactor code
ah yes
i often split my tests into 2 functions
1 just holds all the setup and expected outcomes
and the other does the “stuff"
because you need div
as both a symbol (so you can read the name) and as a function
like if you had a function that would loop over the things and test them you'd need to do:
(test-primitives
div 'div
span 'span
...
which is still not bad
ah i see
most of the tests i’ve written were in PHP
you probably don’t want to know how it works there 😉
although i can't say we had too many tests for the 250K lines of PHP in that application
you can just run your strings as functions
aw, i use psysh at work
it’s pretty good
not sure how old it is though
ah, well...
thankfully, if you ever find yourself back in PHP world, there’s a lot less of that going on now, with PSR and composer being common
and there are REPLs that work
it was the worst
they don't use anything
then they went on to re-invent php7, before it was released
fb do weird things sometimes
i had enough clients get mad at me over the years because fb silently dropped/changed/added/blocked something i was using...
and their docs always are wrong/missing
lost all faith
well, i barely get to write code at work any more
and all my evening stuff is in cljs
so i might be slowly kicking the PHP
https://s-media-cache-ak0.pinimg.com/564x/c1/30/67/c13067da6da379571bc2a0aedb8653b4.jpg
repulsive
on that note, i really have to leave
2:30am now