Fork me on GitHub
#fulcro
<
2020-02-23
>
lance.paine14:02:02

Hi all (and I guess, Particularly @tony.kay !), I'm extremely intrigued by the promise of fulcro for a new product.I think it might solve a bunch of practical problems I've struck in the past. I was thinking something in Clojure solves a lot of it, when I stumbled across fulcro, while trying to find out what happened to Om-next As it won't just be me, I'll need to convince others. My concern is it seems there's quite a learning curve to productivity, before it might all click in place. Particularly as my collaborators have little or no clojure experience, vs my little to some :-). The immediate use case is relatively simple, and per @tony.kay's response to this reddit question https://www.reddit.com/r/Clojure/comments/6upzgf/general_consensus_on_fulcro/ for this project it may scarcely matter what we use. But it will inform future direction. Therefore, I'm interested in the most compelling resources/approaches you know? I've watched, and recommended Tom Toor's presentation. https://www.youtube.com/watch?v=PMbGhgVf9Do I've started working through the book and have the very basics going from the template. I found walkable's realworld implementation, https://github.com/walkable-server/realworld-fulcro but lein run just doesn't work

(Caused by: java.lang.IllegalArgumentException: No method in multimethod 'init-key' for dispatch value: :fulcro.module/cljs-build-options)  and the project hasn't been touched for a year. 
The last time I was looking at fulcro (6 months ago, maybe?) it seemed the book and template project was in a limbo between 2.x and 3. I get the impression that 3 is now the place to start?

👍 1
alidlorenzo16:02:02

imo watching the youtube tutorial videos (https://www.youtube.com/watch?v=wEjNWUMCX78&amp;t=1s) makes the documentation a lot more digestible

👍 2
myguidingstar16:02:25

@U2LUY0P8B author here. Fulcro 3 has been around for a while. Although Fulcro 2 and 3 share the core ideas, v3 is packed with lots of well thought ways of doing things. You should stick to it instead. The said realword app was developed by me as a way to learn Fulcro 2 myself, so it contains quite a few limitations as a new learner

👍 1
myguidingstar16:02:31

both Fulcro and Duct framework are amazing frameworks, however I don't recommend trying both of them at once. Get familiar with one of them first

👍 1
lance.paine16:02:43

thanks @UPH6EL9DH I had started watching them on a commute, but on a phone screen, so not the most absorptive 🙂 I'll definitely go through them at my computer

lance.paine16:02:30

thanks @U0E2YV1UZ I recognised the name immediately 😉 part of the reason fulcro is so appealing is it reminds me of a lot of the patterns I had in an surprisingly novel inhouse framework I was lucky enough to work on in a bank for a number of years, but updated for the web. But then how all of these ideas apply to a language I'm infatuated with, but not aufait/fluent in... well that's the kicker 🙂

currentoor18:02:44

Hey, Fulcro 3 is definitely the one to look at, 2 is only for legacy

currentoor18:02:10

this is a learning curve, but it also depends on your background

currentoor18:02:49

• js/jvm experience • functional programing • intelliJ or emacs experience • etc

currentoor22:02:53

fortunately fulcro is well documented and the book explains everything

holyjak08:02:19

I know Clojure(Script) quite well and have worked with Om and Reagent + Re-frame in the past, as well as with React and JS. So I have quite a good starting point yet I experience there is indeed quite a learning curve. I am quite excited about the promise of Fulcro, that's why I am working hard to learn it enough to try to sell it to my team instead of TypeScript+React+Redux. If you are quite new to ClojureScript and your needs don't warrant the use of Fuclro, I would strongly consider starting with Reagent (+ Re-frame). I think it is much easier to start with and it worked well on my previous teams. Come back to Fulcro when you have experiences with ClojureScript frontend development. That's my 2 cents. On the other hand, if you have the time to really dive into Fulcro, learn it well, implement something in it before selling it to your team, then feel free to go ahead 🙂

👍 1
ballpark22:02:16

Interesting perspective @U0522TWDA. I have some personal project experience with Reagent and Reframe. I recently watched Tom Toor's talk too, and found his arguments convincing. However, Fulcro does seem like a lot to digest. Also, the fact that you're recommending Reagent and Reframe for starters gives me pause. It seems like a good SPA framework should be helpful for beginners and experienced alike. It seems like learning an "inferior" framework before moving on to a superior one would be a waste of time.

holyjak07:02:48

Fulcro is "batteries included" - it gives you more but requires more investment from you. Reagent is not inferior, is just better match for different products.

sheluchin14:02:32

I'm looking for an example of how to use data from a third party REST API in my Fulcro application. Can anyone point me towards such a thing?

sheluchin15:02:57

I'm guessing I would need to use something like clj-http in a Pathom resolver to achieve that?

fjolne16:02:10

@alex.sheluchin you can • make requests from pathom resolvers/mutations (with clj-http or any other http client) • make requests from browser (with ajax-cljs or cljs-http or anything) the more interesting question is how to normalize/store/sync 3rd party data, but that depends on the problem

👍 1
sheluchin20:02:58

Do you happen to know of any resources that explain these points explicitly?

fjolne05:02:32

I guess the best resources are just those libs READMEs, it’s actually pretty straightforward: make a request => process the result. In case of clj-http you’d probably want to go with a synchronous version (default), so that’s just one function call.

fjolne06:02:06

The normalize/store/sync part depends on your problem and stack. Like, you might want to have a scheduled job for syncing, or to use Datomic’s report-queue, or you might just make a request every time you need this data, or... so that depends

fjolne08:02:39

in case you make requests from browser, say with ajax-cljs, it might be something like

(ajax-request
  {:uri             ""
   :method          :get
   :headers         {...}
   :format          (json-request-format)
   :response-format (json-response-format {:keywords? true})
   :params          {...}
   :handler         (fn [[ok? result]]
                      (when ok?
                        (comp/transact! app [(save-result {:result result})])))})
where save-result might be something like
(defmutation save-result [{:keys [result]}]
  (action [{:keys [state]}] (swap! state assoc ::result result)))
and then you can access it from components via link query

fjolne08:02:03

or you may save it as an attribute of particular component and access just like any other attr (without link query)

fjolne08:02:55

something like that inside of save mutation

(swap! state assoc-in [:component/id :my/component :result] result)

fjolne08:02:24

and then

(defsc MyComponent [this {:keys [result]}]
  {:query [:result]
   :ident (fn [] [:component/id :my/component])}
  (dom/div result))

sheluchin11:02:42

Thanks very much! This should be plenty enough direction for me to try it out.

daniel.spaniel19:02:01

i am having the hardest of times doing a simple df/load like this one

(df/load this :dataico/analytics-data nil
    {:target (conj admin-analytics-ident :ui/analytics-data)})

daniel.spaniel19:02:40

I get data back in an array but I get errors deep in mutation land that say

core.cljs:1226 Uncaught Error: :dataico/analytics-data is not ISeqable
    at Object.cljs$core$seq [as seq] (core.cljs:1226)
    at mutations.cljc:311
    at core.cljs:4406

daniel.spaniel19:02:25

I do this elsewhere and it works fine .. the return is an array of data but something wants an ISequable

daniel.spaniel19:02:18

:dataico/analytics-data
 [{#inst "2020-02-01T05:00:00.000-00:00"
   {:count 3, :active true, :paid-up true},
   :company/id #uuid "87b86c2e-19a5-4434-be61-ba395dc14e53",
   :name "Acme"}]}

tony.kay19:02:16

@dansudol what’s on line 311 of mutations.cljc (or is that my mutations ns?)

daniel.spaniel20:02:44

its this line Tony

(fn [m] (some-> m seq first meta :fulcro.client.network/progress-mutation add-progress))

tony.kay20:02:19

I’d guess m is the keyword

daniel.spaniel20:02:21

in the function

progressive-update-transaction

tony.kay20:02:38

and you don’t expect it to be

tony.kay20:02:44

put a log/spy in there

daniel.spaniel20:02:50

errr .. i can do that /

daniel.spaniel20:02:42

I am trying to set breakpoint in there now and see what i see

daniel.spaniel20:02:50

looks like it gets the data but there is error on formatting

In CLJS DevTools 0.9.10, an exception was raised during value formatting.

tony.kay20:02:11

use js/console.log before the thread

daniel.spaniel20:02:07

m is :dataico/analytics-data

daniel.spaniel20:02:46

in the other m values i saw where all maps or arrays with 5 empty things

daniel.spaniel21:02:56

you can't do a df/load with just a keyword ( I think that is a bug in F2 )

daniel.spaniel21:02:05

I added params to the df/load like so

(df/load this :dataico/analytics-data
    {:params {:term       "moo"}})
and now the query to pathom looks like
[:dataico/analytics-data {:term "moo"})]

daniel.spaniel21:02:25

which is >> Iseqable <<

tony.kay21:02:52

load should accept nil for the component…has for quite some time

daniel.spaniel21:02:02

don't follow you, i was using nil like

daniel.spaniel21:02:15

(df/load this :dataico/analytics-data nil {}) 

daniel.spaniel21:02:59

already .. the fix was to add params to make the query from :dataico/analytics-data to [:dataico/analytics-data {:params blah}]

sheluchin23:02:43

I'm getting this error in the console and hot reload is not working: > failed to load com.fulcrologic.fulcro.specs.js Error: Unable to resolve spec: :edn-query-language.ast/node

sheluchin23:02:29

Anyone know what the reason might be?

tony.kay23:02:14

@alex.sheluchin could be you’re pinning your EQL dependency to an earlier version. Might also make sure you guardrails.edn (if you have one) is set to emit specs.

tony.kay23:02:02

failures to resolve specs means just that: we use specs in various ways to do loose type checking at dev time. For some reason the definition of that spec is missing in your build.

sheluchin23:02:01

Is it likely to also be the reason for hot reload not working, or is that more likely to be something else?

tony.kay23:02:36

that is the only reason