This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-01-17
Channels
- # aleph (3)
- # announcements (12)
- # beginners (80)
- # boot (3)
- # braveandtrue (16)
- # calva (3)
- # cider (82)
- # clojure (100)
- # clojure-art (3)
- # clojure-dev (79)
- # clojure-estonia (1)
- # clojure-europe (4)
- # clojure-finland (15)
- # clojure-indonesia (1)
- # clojure-italy (20)
- # clojure-nl (4)
- # clojure-spec (24)
- # clojure-sweden (2)
- # clojure-switzerland (1)
- # clojure-uk (99)
- # clojurescript (145)
- # cursive (8)
- # data-science (7)
- # datomic (26)
- # emacs (4)
- # figwheel-main (20)
- # fulcro (8)
- # graphql (3)
- # hoplon (2)
- # jobs (1)
- # kaocha (5)
- # leiningen (2)
- # liberator (19)
- # off-topic (16)
- # pathom (9)
- # perun (1)
- # portkey (2)
- # re-frame (17)
- # reitit (1)
- # shadow-cljs (26)
- # spacemacs (7)
- # vim (49)
Anyone knows how, using bidi clientside, I can let a pattern ”escape” the router and thus my SPA? I want /api
to result in a request for the web server and /<anything else>
to be routed inside my SPA. My google fu only digs up an old blogpost of my own writing, which does not answer this question…
@pez https://github.com/venantius/accountant I think you need this
(ns form-validator-demo.routes
(:require [re-frame.core :as re-frame]
[bidi.bidi :as bidi]
[accountant.core :as accountant]
[taoensso.timbre :as l]))
(def route ["/" {"" :main
"log-in" :log-in
"log-out" :log-out
"sign-up" :sign-up
"forgotten-password" :forgotten-password}])
(defn path->request [path]
(bidi/match-route route path))
(defn handler->path [handler]
(bidi/path-for route handler))
(defn navigate! [path]
(accountant/navigate! path))
(defn hook-browser-navigation! []
(accountant/configure-navigation! {:nav-handler (fn [path]
(re-frame/dispatch [:load-path path]))
:path-exists? (fn [path]
(l/info "exists?" path (bidi/match-route route path) (boolean (bidi/match-route route path)))
(boolean (bidi/match-route route path)))})
(accountant/dispatch-current!))
and do something like that@kwladyka: thanks, I am using Accountant as it happens. I'll fiddle some with my path-exists? handler and see what it gets me.
I've found kibu/pushy to be much simpler to use
Part of my problem is that we have a simpler syntax for the bidi table, that we transform. I am trying to figure out what our syntax allows.
I think the bidi syntax is simple enough. But people borked it all the time, and someone decided to wrap it.
For me bidi syntax is perfect. At least I don’t have better idea how it could be done better
I am not very familiar with it. I think it depends on the use case. Fore huge routing tables, it offers speed, even speed matching Pedestal's. And also, from what I have seen, it's syntax would trip my colleagues a bit less. 😃
@borkdude before going with bidi, I'd suggest checking out reitit. (iirc they have bundled a html5 handler with it).
but reitit sounds good yes. we’re using yada on the backend which is coupled to bidi.
yada and bidi aren't coupled. They just suggest you use bidi as that is also their library and they know it will work as intended together. You're free to use any other library.
Didn't see that yet, sorry
btw, secretary is now a clj-commons project. at least it’s in maintenance mode. https://github.com/clj-commons/secretary
@borkdude yada isn't coupled to bidi, but does provide convenient integrations with it.
@kwladyka you can use ring stuff with yada, although we got rid of a lot of the ring stuff we had. see https://twitter.com/borkdude/status/857979807358910464
good, I was trying yada a few days, but I had feeling it needs +1 year. Maybe I give up too fast. hard to say
@dominicm now that you say this, maybe we could use reitit with yada then. it also replaces Schema by spec for validation? then we could migrate that too. do you know any projects that did this?
reitit and yada accomplish the same thing so you wouldn't use them together.
Reitit does more than routing
They have a separate documentation link on there as well
I read that, but from that I understood it’s a routing lib. not clear to me that you can’t plug it in like bidi in yada
I do suggest you just use bidi since it is designed to work together
It does do some things for you automatically by including it, if that's what you mean, sure.
I just deployed a website with yada and bidi on the backend API and re-frame, bidi, and pushy on the front-end. Worked very well together
yeah, we already had the front-end before yada, but bidi would make sense when redesigning it
yeah, that's the beauty of the front-end not being coupled with the back-end
I have feeling doc could have 20% of the content with the same or higher value. Just I couldn’t achieve things. Like for example I didn’t want to throw exceptions to users face in web browser. How to turn off it? Somebody point me on #yada to place in the code, but there is no word about that in doc. In other words IMO the weakest point of yada is doc.
I'm not even sure what you mean here. I don't have any errors being thrown to the user on my site...
Again, no idea what you mean specifically. Showing the actual code would be helpful...
Liberator is for creating ReSTful resources so it's not a replacement for yada. Liberator is used in conjunction with ring to provide the serving of the data. That's what yada does. You can use liberator with yada, but it does not replace it. The documentation for Liberator uses Compojure for the routing, but suggests bidi as an alternative, which is the recommendation with yada.
I know. So how do you hide exception on web page when 404? I will give yada a second chance today probably 🙂
I don't know the answer to that, but it could be a development mode only thing. Have you tried making a production build just to see if it does it there? For me it doesn't return a 404, but instead a 204.
Hmm so you are saying with :adavanced
compilation it could work differently? I have never seen such solution. But who knows. I didn’t try it.
Anyway I will try yada again today with more experience after liberator and things around. It could help.
I would love to use it, but today I don’t feel comfortable with it. Maybe I should try once again.
at least there are docs, although they’re not complete. when I did a comparison between Pedestal and yada, I found yada much more accessible doc-wise
It is missing some things. I was told by Dominic that he just consults the tests for those pieces until they are fully documented.
@kwladyka as for the error handling code. I can post my code if you want to have a peek
I removed some specific things to our app, but this is the gist of it: https://gist.github.com/borkdude/441379ec59d8da7f72348453ee15f32a
in dev I throw exceptions at my face in the browser, but in prod I don’t (they’re logged to sentry)
that’s an entirely different topic, but right now we don’t. I suggest talking in #yada, since this is going off topic now
but probably auth has to be moved into graphql and there is really no library to support it
My hacky macro to get translations hooked up in CLJS actually paid off. I’ve closed the circle and now can upload my .pot files to translation, and read back .po files (using pottery). Good stuff! :happy-dance:
@orestis cool. are you by any chance using https://github.com/brightin/pottery?
Yes, but only to parse .po files. I generate my own .pot files because I needed to do the pre-processing of messages on my own.
I’m trying to create a macro which is the combination of go and let. What is very bizzare is that every time I try to evaluate the macro I receive the information that var cljs.core/destructure is undeclared 😮 How to make it work? What I’m missing?
(ns some-example.macros.async
(:refer-clojure :exclude [destructure])
(:require
[clojure.core.async]))
#?(:cljs
(defmacro go-let
[bindings & body]
`(clojure.core.async/go (let* ~(cljs.core/destructure bindings) ~@body))))
Anyone know how to do it?
anything you put into ~(...)
must be valid clojure code, where did you require cljs.core namespace?
Because I would still to destructure bindings
Ok I got it. let will do it for me 😄 Thank you @U0J9LVB6G
You’re completely right 🙂
@U0J9LVB6G I’m still struggling with this one:
(ns some-example.macros.async
(:require-macros
[cljs.core])
(:require
[clojure.core.async]
[cljs.core]))
(defmacro go-let
[bindings & body]
`(clojure.core.async/go
(cljs.core/let ~bindings ~@body)))
It seems that the bindings are nil 😮 How come?
What is even more bizzare is that it works perfectly fine in plain clj.
(defmacro go-let
[bindings & body]
`(clojure.core.async/go
(let ~bindings ~@body)))
(go-let [a 1]
(println a))
Is it caused by the fact that I got it defined in cljc instead of .clj? @dnolen?It's considered rude to @ people that are not a part of the conversation at the moment.
About your problem, you should just use let
instead of cljs.core/let
. That last version should work in a cljc file as well.
Well dnolen already was a part of the conversation since he was answering my question. Maybe not in that thread but definitely he was involved in helping me. If you feel that my behaviour is rude dnolen, please forgive me. I’m sorry if you feel offended.
@U0J9LVB6G I’m receiving the error:
[Figwheel:SEVERE] java.lang.ClassCastException: clojure.lang.Keyword cannot be cast to clojure.lang.IObj
Could not Analyze <cljs repl> line:1 column:1
clojure.lang.Keyword cannot be cast to clojure.lang.IObj
1 (masync/go-let [a 1]
^---
2 (println "abc"))
(masync/go-let [a 1]
(println "abc"))
after using the last snippetOk solved the issue 😄 I had to add macros from cljs.core and require the cljs.core 😄
(defmacro defstart! [args & body]
`(do
(defn ~'-start! ~args
~@body)
;; check if we're in node; if not, don't create the reloadable start
(when-not (cljs.core/exists? js/process)
(defonce
~(with-meta 'start! {:export true :dev/after-load true})
(hecate.loader/reloadable (var ~'-start!))))))
seems not to be working for mein our project, we have a lot of entry points into various parts of the app. each entry point has a bunch of boilerplate
e.g.:
(when-not (exists? js/process)
(defonce ^{:export true :dev/after-load true} start! (reloadable (fn [dom-ref {:keys [config]}]
(r/render [app config])))))
I'm trying to clean this up with a macro:
(defstart! [dom-ref {:keys [config]}]
(r/render [app config]))
I see you just want to make a macro that expands to a def w/ metadata, that should work
(defonce
~(with-meta 'start! {:export true :dev/after-load true})
(hecate.loader/reloadable (var ~'-start!))
I've done this recently with vary-meta, it works
But in a macro
Macro time
Let me find it
I don't see anything obviously wrong at the moment, but can't look too closely right now
@kwcharllie379 you're not requiring the cljs.core
macro ns so that won't work