Fork me on GitHub
#fulcro
<
2019-06-14
>
tony.kay01:06:53

working on it…but wow, lots of effort

tony.kay01:06:15

@uwo I think you might be misunderstanding something…lookup refs are a server concern. Using something like :account/id as the id attribute of something is perfectly reasonable, and can just be the value (not the lookup ref from the server).

tony.kay01:06:41

The entity on Fulcro would just be {:account/id some-uuid ...}, and the form field would just be :account/id

tony.kay01:06:01

the fact that relations in fulcro also use idents that look like lookup refs then “jsut work” when you get the diff on the server

tony.kay01:06:58

alpha-7 is on clojars, and the template app has been updated to use the dynamic router and ui state machines…it’s still a bit messy and incomplete, but might be interesting as reading material

tony.kay01:06:50

Today’s effort was mainly writing more code and fixing issues as I found them. UI state machines is better tested (it had issues), and dynamic routers have fewer required parameters on route targets.

uwo04:06:12

In the case I had in mind, we have no need to store the entity on the client. The lookup ref would only be a value on form. This comes up lot for us: forms with fields for selecting domain entities that needn’t be stored on the client

tony.kay05:06:42

@uwo So, form state should consider any non-join attribute as an opaque value, including those that look like idents. If that isn’t the case, then I would consider it a bug, and would certainly accept a patch.

🙏 1
geraldodev11:06:55

The synergy of libraries in the new template is so beautiful. https://github.com/fulcrologic/fulcro3-template/blob/master/src/main/app/model/account.clj#L30 . ghostwheel is new to me. I'm going to use it.

🎉 3
tony.kay15:06:42

@geraldodev Thanks…I’m still working on getting the error messages to be readable with ghostwheel…expound is great, but when I log with timbre it totally munges the thing into a string and messes up the formatting to be unreadable…quite maddening. I’m trying not to maintain my own logging code, but man I wish the ecosystem was a bit more stable with respect to sane error messages 😜

kszabo15:06:45

If you find a solution to that, I’d be interested, we experience the same thing. Maybe use tap> to send down the nice expound ‘exception’ if it occurs instead of raising/etc. and attach a tap handler to print it to *out* if it matches?

tony.kay15:06:11

The problem happens when I need to catch exceptions to prevent logic problems (e.g. I have a try/catch because I’m calling user code), and I’m in cljc. I do (log/error e ...) and timbre stringifies the js exception (which makes it an unreadable blob). I don’t want to code a solution at each call point, which means writing my own macro, which means maintaining my own logging code….a thing I was trying to get away from 😕

tony.kay15:06:43

I haven’t had the time to dig deeper, but I probably will today just because it costs me sooooooooooo much time and frustration.

tony.kay15:06:13

I think overriding timbre’s default output function could possibly be a fix

kszabo15:06:25

so the root of the problems stems from treating log messages as strings. I just read a blog post about an alternative logging library in cljs land: https://lambdaisland.com/blog/2019-06-10-goog-log here log objects are serialized to strings via dynamically adjustable handlers, which could in theory pprint expound exceptions

kszabo15:06:40

this is pretty incompatible with timbre/serverside logging libs though

tony.kay15:06:15

well, that’s why we have cljc 🙂

kszabo15:06:28

right, but you still have to figure out the clj side 😄

tony.kay15:06:39

but no, I’m no interested in using goog.log

kszabo15:06:05

sure, it would be nice to solve this at timbre level so expound users won’t feel the pain

tony.kay15:06:07

that’s where Om Next started….didn’t work well for what you just said: you have to maintain your own logging lib. Not doing it if I can avoid it. Timbre is quite good’

tony.kay15:06:28

and it is quite pluggable

tony.kay15:06:30

so should be fixable

kszabo15:06:52

I’m interested, we are currently using clojure.tools.logging on server-side. If we can’t fix that with your workaround we’ll definitely switch over to Timbre. Keeping 👀s on the next alpha release 🙂

tony.kay15:06:26

Yeah, this is going to fix it…simply overriding :output-fn with a more complicated thing…working on it

tony.kay16:06:42

OMG…soooo much better!

tony.kay16:06:57

Call to com.fulcrologic.fulcro.ui-state-machines/alias-value did not conform to spec:
<filename missing>:<line number missing>

-- Spec failed --------------------

Return value

  false

should satisfy

  nil?

-------------------------
Detected 1 error

tony.kay16:06:05

in js console from an internal nested exception on ui state machine

tony.kay16:06:21

(log/merge-config! {:output-fn (fn [{:keys [vargs level ?err ?ns-str ?line] :as data}]
                                 (if (instance? ExceptionInfo ?err)
                                   (js/console.log (ex-message ?err))
                                   (log/default-output-fn data)))})

👍 1
tony.kay16:06:50

add in a development_preload cljs file, and good to go…improve from there

exit215:06:36

Is it possible to use form validation when your fields aren’t like ::name and are :name?

exit216:06:38

I suppose the alternative is I can pass a spec ns to the get-spec-validity fn rather than a field name

tony.kay16:06:42

For those out there struggling with cljs error messages as I have been, the result I just got is so heartening that I thought I’d pull it out of the thread. If you’re using timbre you can override the output function and detect all sorts of things abt the error. I’m using ghostwheel/epound and the errors were just globs of crap…I just added this to my dev preload file:

(log/merge-config! {:output-fn (fn [{:keys [vargs level ?err ?ns-str ?line] :as data}]
                                 (if (instance? ExceptionInfo ?err)
                                   (js/console.log (ex-message ?err))
                                   (log/default-output-fn data)))})
and went from 60kb unreadable spec error messages to messages more like this:
Call to com.fulcrologic.fulcro.ui-state-machines/alias-value did not conform to spec:
<filename missing>:<line number missing>

-- Spec failed --------------------

Return value

  false

should satisfy

  nil?

-------------------------
Detected 1 error

🎉 5
tony.kay16:06:24

(expound does the real heavy lifting, but without a custom output fn it just gets tangled up i nthe middle of an unreadable mess of other things and stack trace)

tony.kay16:06:19

going to refine that…I still want the stack trace and such…but I want that to be the last thing output so that the I don’t have to scroll to see the most important info.

tony.kay16:06:41

@njj form validation is completely customizable..you can do what you want. If you mean “does form state currently have something to make non-spec keywords work with namespaced specs?” the answer is “no”

tony.kay16:06:52

spec is spec

👍 1
tony.kay16:06:19

On the logging…I guess technically this should be an appender with a custom output fn…this is supposed to convert it to a string, but I don’t want string conversion…raw output to js/console.log is what I want…so, not technically a correct way to configure it, but it is for development cljs only anyhow

tony.kay17:06:43

Here’s what I ended up with so far for fixing the logging…any further changes will appear in the preload on the template: https://github.com/fulcrologic/fulcro3-template/blob/master/src/main/app/development_preload.cljs This is working pretty well for me.

tony.kay23:06:20

Wrote a new Intro chapter in the book today. Anyone caring to comment/proofread/learn/make-fun-of 😜 : https://github.com/fulcrologic/fulcro-developer-guide/blob/master/DevelopersGuide.adoc#fulcro-from-10000-feet

3
Shan12:06:51

I started exploring fulcro recently and this helps a lot, thank you! Btw, do you have any good tips for an introductory book or article about graph theory?

tony.kay13:06:04

Glad to hear it. I do not have any book recommends. The graphs we’re using in Fulcro probably don’t need much in the way of textbooks to understand…just nodes and edges connected in whatever way makes sense for your application.

Shan13:06:01

Thank you for the reply! It’s really nice to get confirmation that everything is designed to be so approachable. Cheers

tony.kay23:06:12

did some other work on getting book demos working and such, but not publishing this where you’d see that yet

tony.kay23:06:44

(note to newbies…that version of the book is for v3, not the current production Fulcro 2.x)