Fork me on GitHub
#fulcro
<
2020-03-12
>
tony.kay13:03:47

the output of defsc is a js class, which is nothing more than a function that has crap in .-prototype and such. See js docs. If you’re asking me “How do I get defsc to let me write methods on the class?” The current answer is “it won’t”. You could easily write an (add-method! cls nm (fn ...)) function that adds a method to the class. Just look at how you’d do that operation in js and mimic it. Roughly this:

(ns util
  (:require 
    [goog.object :as gobj]))

(defn add-method! [cls nm f]
  (set! (.. cls -prototype nm) f))

(defn add-methods! [cls map-of-methods]
  (gobj/extend (.-prototype cls) (clj->js map-of-methods)))

...

(defsc X ...)
(add-methods! X {:newMethod (fn [] (this-as this ...))
                 :otherMethod (fn [] ...)})

tony.kay13:03:59

“statics” just go directly on the class instead of the -prototype

tony.kay13:03:51

The component options map is technically open. I’d consider a PR to let you add them there, I just have never needed it myself.

tony.kay13:03:04

I think gobj/extend has been deprecated in favor of something…oh right, Object.assign…whatever

tony.kay14:03:17

For those playing with RAD: The alpha-8 release of the Datomic adapter (and the latest demo on develop of the demo repo) have some useful changes: 1. rad-datomic now has much more extensive tests 2. You can now put ::datomic/native-id? true on an identity attribute to have to map to :db/id in the database (you should still give the ID an application domain name like :person/id ) 3. The demo now uses Datomic free in memory, with no dep on postgresql or running an external transactor. This makes it much easier to get started with the demo, as it is now a zero-install experience.

tony.kay16:03:13

I’d appreciate it if someone was willing to clone the demo and try the Datomic instructions. It should be a clone, yarn, shadow-cljs, clj sequence that should work without hassle (or separate downloads).

👍 4
👀 4
cjmurphy17:03:37

That's what I get from starting off with npx shadow-cljs watch main and following its instruction exactly.

cjmurphy17:03:29

Doing an npm install first meant that that issue didn't crop up. I don't have yarn.

tony.kay17:03:06

ok, trying myself with npm

cjmurphy17:03:00

It all works for me now, at usual uri for shadow and making sure no index.html for the client.

tony.kay17:03:42

did you change anything?

cjmurphy17:03:19

(Having the shadow server running at http://localhost:9630/)

cjmurphy17:03:03

No - just ran the instructions, but w/out yarn and with the shadow-cljs server already running.

tony.kay17:03:09

I don’t understand. I’ve tried here and cannot make that error happen.

tony.kay17:03:24

oh, you’re saying you ran shadow before doing an npm install?

cjmurphy17:03:46

Yes it is always there from usual project.

cjmurphy17:03:08

shadow server always up

tony.kay17:03:32

oh, so it connected to a shadow server running the wrong classpath

cjmurphy17:03:25

Yes I guess so. My mistake was not running npm install first up, I believe.

tony.kay17:03:01

I added that to the readme just now, since a lot of ppl prob won’t use yarn

cjmurphy17:03:19

I can log in but when I press My Account I get an error. But that's another thing I guess.

tony.kay18:03:22

Hm…that’s strange

tony.kay18:03:43

you started the server with the appropriate deps options?

tony.kay18:03:04

I guess it would not have started otherwise

cjmurphy18:03:30

Maybe not. Just did clojure.main IntelliJ REPL with dev,datomic as aliases.

tony.kay18:03:58

I would expect that to work

keoko17:03:00

I’ve just followed the datomic instructions and it worked perfectly for me.

cjmurphy05:03:27

This is logging before the error. The message comes from the function com.fulcrologic.rad.authorization/-reply-to-initiator, so a :source-machine-id could not be retrieved. 

tony.kay15:03:24

Strange, as if the auth machine didn’t get started