Fork me on GitHub
#fulcro
<
2019-11-24
>
mdhaney02:11:24

@geraldodev no examples that I know of, but it was very easy to get going using https://github.com/fulcrologic/fulcro-websockets . The Readme has pretty good instructions - give it a try, and if you have any problems, I’m sure someone here can help.

currentoor02:11:16

I gave a talk at the conj, it’s on youtube https://youtu.be/PMbGhgVf9Do

👏 36
pithyless10:11:21

I went down an unfortunate rabbit hole today. So maybe this will be useful to someone. Setting up a new project, I added fulcro-spec as per the fulcro-template (which happens to use kaocha, but does not include :reporter [fulcro-spec.reporters.terminal/fulcro-report] in the tests.edn config. I totally missed that in the fulcro-spec README until after I figured out the issue. The problem is, everything seemed to work except for pretty-printing of large diffs. Which meant I went down a rabbit hole of figuring out what is wrong with my kaocha config. In reality, it's this bit of code:

(defn assertion-type
  "Given a clojure.test event, return the first symbol in the expression inside (is)."
  [m]
  (if-let [s (and (seq? (:expected m)) (seq (:expected m)))]
    (first s)
    :default))
kaocha expects an event with {:expected '(= foo bar)} but fulcro-spec is in fact generating something akin to {:expected 'foo}, which is then defaulting to an unknown reporter that tries it's best to pr-str whatever was :expected and :actual. In fact, just requiring fulcro-spec macros is enough to break the build, even if I use regular deftest/is in the code. I'm not even sure if this is an oversight and can be easily addressed in fulcro-spec or if this would require lots of work and breaking changes. Either way, it's a cautionary tale.

tony.kay12:11:30

Thanks for describing that…sounds like an easy fix. Open an issue when this info and we’ll have a look

tony.kay12:11:47

just a mistake on the part of fulcro spec it seems

yannvahalewyn13:11:55

@tony.kay Just saw the RAD video! Here’s a spitball thought thread. I spent the weekend looking around the ecosystem for new and old ideas. I discovered Duct. Now I spent 2 days with duct and 10mins with your video, so I definitely don’t know everything about everything. But here a little thought: Very light summary of duct Basically Duct aims to declare your system (mainly back-end) with data. It’s a framework that generates Integrant systems, and comes with some pre-fab modules for the basic needs. The one thing I like is that the maker of Duct differentiate’s between modules and components, where a component is what you’d expect (a router, db, webserver), but a module can generate and manipulate the entire config. For example, let’s say it’s 2009 (oh 2009 <3) and you’re writing a rest crud app. You could write out every route for a given resource, or you could just include a rest module that merges in REST routes for a given resource and connects them to handler dispatch keys following a convention. That module is also configurable. More magic, less control, but it’s magic on demand like you said in the video for those places where it’s just fine. RAD I think it seemed very open to change, but every attr is wrapped in a macro defattr. Macro’s are less composable than data. It’s harder to generate macro’s without generating a code file or knowing about the macro’s internals. Do you think it’s possible to have RAD be expanded from a datastructure instead of macros? That way other libraries, people, could hook into that part as well, and even generate RAD schema’s based on other inputs etc..

tony.kay13:11:10

So defattr just registers the attribute for you…it just defs a map otherwise, so the answer there is “yes, easily”

tony.kay13:11:34

you could collect them all up into a schema map, and then call a funciton to build the system

tony.kay13:11:47

this is 4 days of dev, so API is not set in stone on any angle

yannvahalewyn13:11:03

Of course not, that’s why I’m intervening so annoyingly

yannvahalewyn13:11:09

But that’s great!

yannvahalewyn13:11:15

If that’s the case, this could be huge imo

tony.kay13:11:45

One goal is great error messages, so I sometimes lean on macros because they can give you immediate feedback when you screw up and good error messages

tony.kay13:11:56

and clojure still sorely lacks that

tony.kay13:11:20

My defsc macro just calls configure-component!, but it checks things like “did you destructure something in props you didn’t query for”

tony.kay13:11:24

saves tons of dev time

yannvahalewyn13:11:25

why would macros provide better errors?

tony.kay13:11:41

and I can give an accurate error: You didn’t query for X

tony.kay13:11:44

and explain

tony.kay13:11:54

much much better experience for beginners and me alike

tony.kay13:11:44

Macros are compiler extensions…compile errors are useful in many cases where static analysis can tell you abt problems

tony.kay13:11:21

core async isn’t even possible (as designed) without macros that convert clojure into state machines…they pre-compile your clojure into different clojure

yannvahalewyn13:11:52

I realised I could’ve summarized my shpiel by could rad be data driven instead of macro driven haha

yannvahalewyn13:11:10

exiting stuff @tony.kay! Have fun at the conj 🙂

tony.kay13:11:43

conj just ended…headed out today. RAD is data-driven…but I agree with your point, perhaps macros are not right in the data model at all

tony.kay13:11:59

simple enough the check the maps later

tony.kay13:11:55

RAD is 4 days of conference-driven development…design work was not in any way careful 😜

tony.kay13:11:32

but it shows how easy Fulcro + Pathom are starting to make things

geraldodev13:11:53

I've started to enjoy mount that I discovered via fulcro template. It's way less complexity than component and yet a library. One can adopt (like I did) or go for other library or framework (like duct). It is a lovely choice because it reduces the complexity.

tony.kay13:11:13

I just did a meet-up about where Fulcro is going, for contributors…here are the slides if anyone wants to help: http://book.fulcrologic.com/Fulcro-needs.pdf

👍 4
tianshu14:11:28

just start to study fulcro via the video tutorial on youtube. this is really awesome.

tianshu14:11:47

I wonder is there something tell about how to do routing with fulcro?

cjmurphy05:11:27

There are a couple of options. AFAIK the dynamic router works for all situations however: http://book.fulcrologic.com/fulcro3/#_dynamic_router

sheluchin14:11:53

I'm building out a simple poker game. My application has a Deck component. My understanding is that I'll only need a single :deck/id on which I will run mutations throughout the game. As cards are dealt out and collected back, :deck/cards gets updated to represent the change. Does that sound right? Is there any technical case where I should be create a new :deck/id and working with that instead of the original [:deck/id 1]?

cjmurphy20:11:50

Yes that sounds fine. No, a singleton will be fine. If your card game later requires multiple decks then change things then. You won't have incurred any technical debt by going with a singleton. Also in your application 'panels' will be singletons. The only things not to be singletons are obvious 'many-s', such as cards.

tianshu16:11:46

@alex.sheluchin as what I learn from the video tutorial of fulcro, If you have some singleton component, you can give it a constant :ident, by provide a lambda:

:ident (fn [_ _] [:component/id ::name-of-this-component])
looks something like this.

sheluchin16:11:33

Does a singleton make sense? Is it the right abstraction? I guess I'm dealing with a conceptual conflict between data being immutable and maintaining the same id while creating a mutated copy.

currentoor22:11:27

the copy should have a different ident

currentoor22:11:48

have you looked at how form state support is implemented?

currentoor22:11:48

when editing an entity in a form, it makes a pristine copy (in a different location), if you cancel out of the form it reverts the entity using the pristine version

currentoor22:11:09

you can use the inspector tool to see how it’s done in this demo http://book.fulcrologic.com/#_form_state_demos

sheluchin12:11:10

the copy should have a different identWhen you edit a phone number in the form state demo, it changes the properties on the same [:phone/id 1] ident; it doesn't create a new ident with the new details. I haven't read that far into the docs yet, I'm guessing it explains it later. I'll check out the sections you linked. My main question is this: if I have a [:deck/id 1] ident, and within that there is a :deck/cards , and I remove a single card from that deck, does the resulting deck (same as 1, less one card) need a new ident? Does it become [:deck/id 2] with one less item in :deck/cards, or do I just update deck 1? I asked the same question here: https://clojurians.slack.com/archives/C68M60S4F/p1574626970497600?thread_ts=1574607533.487300&cid=C68M60S4F and I'm getting a little mixed up between your answer and @U0D5RN0S1's

cjmurphy15:11:12

No it doesn't need a new ident. [:deck/id 1] is your deck of cards. [:deck/id 1 :deck/cards] is the location where the cards are kept in that deck. If you remove the joker then that location will have one less card, one less ident. Actually copying state is something you are unlikely to be needing to do in your first experimental application. If you had another deck of cards it would be [:deck/id 2] and would have its own set of idents. You might for example move [card/id :black-joker] from location [:deck/id 1 :deck/cards] to [:player/id 1 :deck/cards] .

tianshu17:11:44

@alex.sheluchin if you only have [:deck/id 1], you just ensure this ident is unique, IMO

tianshu17:11:23

it doesn't make much sense.

sif17:11:21

Hello, I have noticed that entity->pristine* stopped working from version 3.0.2 to 3.0.3 (it works like expected in all versions prior to 3.0.2). This can be tested using video example under tag rendering-part-2.

currentoor22:11:46

@U0MK9B06T can you please file a github issue with steps to reproduce, expect outcome and actual outcome?

sif18:11:22

No problem.

geraldodev20:11:22

When pressing : on query tab on fulcro inspect chrome brings the settings. Are you experiencing this too ? Do you know a way to disable this shortcut ?

currentoor22:11:24

I just checked and I do not see this behavior

currentoor22:11:47

i’m on a mac, might be something specific to your setup

geraldodev23:11:04

@U09FEH8GN Thank you. I'm on linux