This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-10-23
Channels
- # 100-days-of-code (2)
- # aws (1)
- # beginners (105)
- # boot (36)
- # calva (4)
- # cider (56)
- # clara (37)
- # cljdoc (16)
- # cljs-dev (19)
- # clojure (44)
- # clojure-dev (20)
- # clojure-italy (24)
- # clojure-nl (3)
- # clojure-serbia (2)
- # clojure-spec (15)
- # clojure-uk (44)
- # clojurescript (41)
- # code-reviews (3)
- # core-async (12)
- # cursive (24)
- # datomic (4)
- # emacs (1)
- # figwheel-main (10)
- # fulcro (168)
- # funcool (2)
- # hyperfiddle (15)
- # jobs (2)
- # jobs-discuss (79)
- # juxt (19)
- # lein-figwheel (1)
- # leiningen (2)
- # luminus (14)
- # mount (8)
- # nrepl (9)
- # off-topic (9)
- # other-languages (1)
- # pathom (32)
- # reitit (6)
- # ring-swagger (3)
- # shadow-cljs (10)
- # slack-help (11)
- # spacemacs (20)
- # sql (29)
- # tools-deps (28)
- # vim (29)
- # yada (4)
I’m getting this weird behavior using fulcro spec in the browser. I have a test that is showing in the spec UI (with no tags like :focused
) and when I change the test the defines the mutations (not the test file), my spec disappears from the fulcro UI. I start changing the test file and the spec comes back green.
@pvillegas12 make sure you’re on the latest version. I tried to fix that, but am not sure why it happens
I’ve seen it as well, but I don’t really have a clue…is the console saying anything?
It warns about the Root render taking too long
50ms-54ms
@tony.kay still getting the same behavior after updating :thinking_face:
this happens when I save the file that defines the function under test
yes, using shadowcljs
I'll see if I can adjust the :browser-test
target. I did not account for side-effecting macros in the :runner-ns
@U05224H0W including the namespace of the spec in client-test-main
did the trick thanks! 😄 Do let us know when there is a better one 😉
sweet! Thanks @U05224H0W
@U05224H0W I noticed some weirdness with the tests, it appears hot code reloading is not working
for example if i add a top level print statement, i see some activity in the JS log about reloading but none of my print statement
similarly, updating tests seems to have no affect either
and there is this error in the JS log
goog.net.xhrio.js:627 OPTIONS 405 (Method Not Allowed)
Failed to load : Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '' is therefore not allowed access.
@U09FEH8GN out of curiosity, does using “http://test.lvh.me” instead of localhost change anything?
nope, same error and behavior
the error has
instead of localhost
just that request the error logs is failing no other network activity
@U09FEH8GN is that new or was it always that way? I do set the CORS headers so it should be working?
Request URL:
Request Method: OPTIONS
Status Code: 405 Method Not Allowed
Remote Address: [::1]:9630
Referrer Policy: no-referrer-when-downgrade
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Connection: keep-alive
Content-Length: 0
Date: Tue, 23 Oct 2018 21:52:24 GMT
Expires: 0
Pragma: no-cache
Accept: */*
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
Access-Control-Request-Headers: content-type
Access-Control-Request-Method: POST
Cache-Control: no-cache
Connection: keep-alive
DNT: 1
Host: localhost:9630
Origin:
Pragma: no-cache
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.67 Safari/537.36
@U05224H0W definitely broken in 2.6.15, but works in 2.6.13
I’m working on the same source as @U09FEH8GN
Thanks 😃
@U05224H0W golden…works perfectly, and maybe even seems faster than having to pre-require everything
the faster part is from the other changes I did recently. test namespaces generally fit very well into parallel compile and that got way faster the more parallel it gets
hi is any built in http request support in fulcro? what is need is just read …/VERSION file and output it somewhere
or should I use http from Google Closure?
@kirill.salykin There is the network and you have http://book.fulcrologic.com/#_request_middleware the request/response MW think you could just add a new remote with MW that does that request for you, but seems like a bit of work if that's you're only use-case. The network part seem like the only abstraction for http and it uses xhrio directly https://github.com/fulcrologic/fulcro/blob/develop/src/main/fulcro/client/network.cljc#L306
i see, thanks!
it is indeed to much overhead with MW
Yep, did it this way. Thanks )
As anyone worked with rdflib.js
in fulcro, or any sort of parallel client-side store similar to the rdf graph in that library? Would you want to treat that as a remote?
I think that the correct way to do this long-term would be to use something like a SPARQL client / apache jena server-side and go through the normal fulcro flow, but wanted to know if anyone had ideas for a client-side only solution since that would be faster / simpler for a lunch and learn.
@devo pathom has some of these properties, it can run on JVM or Browser and supports parallel processing of the queries, its not RDF, I'm taking a look at the library and seems that pathom connect feature shares some ideas about data linkage, but the implementation is something different https://github.com/wilkerlucio/pathom
the parallel parser is not documented yet (coming soon) but the code is been used in prod for some time, if you follow the pathom docs the configuration is similar to async-parser
, please let me know if you want to try it out
I never got to do some proper research on RDF, could you please tell me what you looking for on it? how it is used? is it like a thing that composes over distributed data graphs?
currently doing a lunch and learn over the SOLID protocol, which is built on RDF, so pretty new to it as well 🙂. The idea is that RDF formats like Turtle or JSON-LD store relationships in triples and are hosted arbitrarily (e.g. https://devereux.solid.community/profile/card#me). You can then use xml describing relationships to query information across those files (e.g. my friends using
. The existing library
is both a web client and a store that fetches remote documents and loads them + their relationships into a client side store for later querying.
@devo for a lunch and learn you could use Datascript to simulate a datomic back-end and a pathom parser as the “remote”
Mostly to show off SOLID, but wanted to do it with fulcro just to get some more experience with the framework.
ok, so since the concept is that you have distributed data stores that all have separate ownership and such, you could set up multiple datascript databases in the browser, and one pathom parser that can resolve to them in a unified query sense (e.g. Fulcro would be unaware that they were federated)
the client-side async pathom parser can do any async kinds of processing, so you could also have it hit a bunch of different real network endpoints
I’m not sure if any of that is relevant, now that I look at some of the introduction stuff on SOLID
this is the solid you are talking about? https://github.com/solid/solid
@devo I don’t really know of anything that is likely to serve your specific lunch-and-learn criteria…seems like using node for a server might be the best you can do, but you could host a single server that everyone could hit, perhaps?
no worries! Was just trying to get some ideas, and definitely have a few to play around with now. Will probably pull in pathom
and start playing around with resolvers / networks to see what seems best.
@tony.kay slightly off-topic question but do you know how to evaluate forms in the clojurescript repl with Cursive? The normal command (eval in REPL) spits “Cannot load ClojureScript form into Clojure repl”
ooh I just realised there is a small dropdown at the top of the repl with “clj” and “cljs” as selections
I’m using shadow-cljs on many different projects (3 commercial). A lot of my older OSS work is on figwheel (as it helps ensure I don’t break users that use figwheel), but I prefer shadow-cljs.
- better responsiveness from the maintainer - better integration with js ecosystem - better caching and cache invalidation (I almost never have to “clean” compiled stuff)
@tony.kay do you have a sample project with shadow? The book uses the Kevin template iirc
you just connect to a remote nREPL from cursive, and type (shadow/nrepl-select :name-of-build)
shadow prints out what port to use, or you can pre-set it (which is what I do so I don’t have to edit the run config all the time)
@tony.kay ah; I was trying to start a repl with npx shadow-cljs cljs-repl watch cards
; I’ll try what you suggest
yeah, I just do npx shadow-cljs watch cards
and use the nrepl port it prints out on startup
shadow-cljs - socket REPL running on port 63355
shadow-cljs - nREPL server started on port 9000
Port 9000 gets me to a clojure repl though, not a clojurescript repl, right?tony.kay [15 minutes ago]
you just connect to a remote nREPL from cursive, and type (shadow/nrepl-select :name-of-build)
@tony.kay one extra question… in the intro devcard file you generate:
(ns elogic.intro
(:require [devcards.core :as rc :refer-macros [defcard]]
[elogic.ui.components :as comp]))
(defcard SVGPlaceholder
"# SVG Placeholder?"
(comp/ui-placeholder {:w 200 :h 200}))
it seems like cursive picks up devcards.core
as a JS dependency. If I CMD-click on devcards.core
it brings me to a JS file, and consequently cursive can’t resolve the defcard
macro. Have you run into this?@tony.kay neither asking to generate stubs, nor indexing. I invalidated caches and restart, still having the issue. I’ll ask on #cursive, thanks
I seemingly wasn’t having that issue with the figwheel setup by the way :thinking_face:
Error generating stubs for module elogic
Java HotSpot(TM) 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
otherwise you have a syntax error that is keeping cursive from evaluating your code, which will prevent stubs from completing
@tony.kay ah, thanks. There doesn’t seem to be more info on why it can’t generate the stubs though 😞 and without them defcard
is not recognised as a macro
@tony.kay actually… after removing the UseConcMarkSweepGC
from the project file the stub generation completed without error. It hasn’t solved the issue with defcard
though
it would be the default instead of figwheel, but I have not had time to rewrite the dev guide
I have to say that I’m a bit confused on how to structure things and get a clojure & a clojurescript repl. Worked on a Clojure / React project before, so never “had” to deal with ClojureScript much
With ui routing I have a top level function nav-to!
similar to the one defined in the fulcro template. I’m having trouble composing this call (which ends up calling prim/transact!
) and other mutations. Say I want to change the state and navigate to another URL. Is the correct way to do this is making a mutation that calls nav-to!
within it? This would nest transact!
calls which I read were not desired
@kardan I recommend using IntelliJ community edition with Cursive…both are free to use for tinkering, and both are reasonably priced for real work. Then use the shadow-cljs version of the lein template…the README it generates should get you going.
I actually bought Cursive to try it but so far I’m using Cider because it’s what I’m used to
understandable…a lot of ppl on channel use spacemacs, and the template is intended to work well with it. Let me know 🙂
@tony.kay bringing the discussion here as it might be relevant to other people trying the shadow-cljs template. Moving the devcards dependency to :dependencies
in the project file (instead of under :profiles :cljs :dependencies
) seems to have fixed the issue for me
Ah wait, I just realised it might have been much stupider than this. Checking the cljs
profile in Leiningen Projects > Profiles
seems to be enough
Sorry, that should have been obvious to me. I just started using intellij :face_with_rolling_eyes:
Yet another question… Has anyone done “query whitelisting” with Fulcro? i.e. list all the queries that the application might run, store those on the server and only accept queries in that set
i.e. indicate, via authorization, which edges of the graph a user is allowed to traverse (and which scalars they can read)…then you can easily look at the query (reduce the keys to a set) to see if there are any “disallowed” keys in the query
you also need to check the “root set” of their incoming request, of course. “Can I start here?”
Namespaces on keywords gives you a nice way of resolving ambiguity that arises from context
but the root set is usually required to make it work right, even with that (e.g. ensuring you don’t walk to another user through edges is easy, but the protections on :user/address might say it’s ok to read…assuring that they don’t start (and cannot traverse through edges) can prevent that.
quick question. I'm getting my backend wired up with pathom (backed by datomic and some other stuff). in say datomic, I use 'discriminator' ID's :person/id
, etc. The client, like say datomic uses :db/id by default. What's the best way to map/translate between the two? Presumably I can override ;db/id on the client, but that seems like it would get messy. And I guess my queries server mutations could do the mapping on the server. Just trying to figure out what makes the most sense.
you’re going to have :db/id no matter what. Add a UUID column for :person/id, which is unique-identity
that way you can still use tempids on :db/id (to detect optimistic results), but pathom will work well because queries can distinguish on discriminator IDs
no. you can query for :db/id if you need it, but :person/id is a unique field that is also identity (UUID)
queries stress using the UUID…mutations send a tempid for :db/id so that you can see when remaps happen…the client can safely generate a UUID for :person/id, but the server need not rewrite it, so there would be no way for you to know (by looking at the data) if the server had succeeded in storing a new one.
elogic.client/app
=> nil
(deref elogic.client/app)
=> nil
(keys (deref elogic.client/app))
=>
(:initial-state
:mutation-merge
:started-callback
:remotes
:networking
:send-queues
:response-channels
:reconciler
:read-local
:query-interpreter
:mounted?
:reconciler-options
:lifecycle
:parser)
@tony.kay it seems like trying to get the app
atom from within the cljs repl returns nil (and throws an error in the browser console).if you want to see the app state value, don’t do it that way…first, you should use Fulcro Inspect chrome plugin…but if you want to play with app state at a REPL, use (prim/app-state (:reconciler @app-atom))
…and that itself is an atom