Fork me on GitHub

I’m adding things to this project board: The cards are things that need to be done in Fulcro, and are probably tractable for a contributor with a little help from me (assuming you have decent Clojure chops). If anyone is interested, let me know.

Jp Soares06:10:17

Does fulcro support webcomponents? I.e. can I use a custom element like (dom/create-element "my-elem")?


If you mean the web components standard: no. But you can wrap things within a React component. See book.


And regular react npm libraries mostly work, if that’s what you mean


Hi, all! Am I correct in thinking that an :ident is somewhat like a primary key? I'm modelling out a deck of cards and would like to avoid giving each card an :id, and instead identifying them by their [:suit :value], like a composite primary key. Is that possible?


@alex.sheluchin An ident is made up of a class/table and an id. The id can be whatever you want, including a composite vector as you are suggesting. So an example ident might be [:card/id [:spades :ace]].


@cjmurphy ah, thank you. Let me try that.


Hmm, not quite getting it:

(defsc Card [this {:card/keys [suit value] :as props}]
  {:query [:card/suit :card/value]
   :ident [:card/id [:card/suit :card/value]]}
    (li "Card: " suit " " value)))
(def ui-card (comp/factory Card {:keyfn :card/id})) 


> The ID property [:card/suit :card/value] of :ident does not appear in your :query at line 20 app/client.cljs


For the ident you need to use a function (a lambda as it says in the documentation).


The ident is formed from props. So write a function that takes props as your ident, for example: :ident (fn [_] (ddu/dd-option-ident props)).


Instead of :dd-kw and :opt-value you would use :card/suit and :card/value.


And of course instead of :dd-option/id you would have :card/id.


@cjmurphy Noted, thanks again. I'm fairly new to Clojure and very new to Fulcro, but I have lots of experience in OOP languages. Still kinda getting the hang of the functional approach. I've been working my way through Brave Clojure, the Fulcro3 dev guide and YouTube playlist. Are there any other resources, besides here, that I should be looking at for questions like this?


As far as other resources go I got some good value from doing 4clojure problems and also 'Advent of code'.


Well some things will take a while to sink in. You don't have to understand everything you use.


I know juxt is pretty advanced. Basically you just need to: [:card/id [(:card/suit props)(:card/value props)]].


I definitely try to use that perspective. Mostly just learning by following the given examples and then implementing my own versions thereof.


Yeah Fulcro is not easy at first. You could also definitely write a card playing program using non-composite ids. And come back to trying out the composite way later.


Yeah, I think I better take that route at first, considering none of the material has mentioned composable ids yet 😛 just trying to think ahead a little, but I guess that'll just lead to road blocks like this until I'm more familiar with the landscape.


Thanks again, @cjmurphy. I'm off for a bit.

simple_smile 4