Fork me on GitHub
#fulcro
<
2019-10-26
>
tony.kay00:10:01

I’m adding things to this project board: https://github.com/fulcrologic/fulcro/projects/3 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")?

tony.kay05:10:25

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

tony.kay05:10:40

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

sheluchin12:10:23

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?

cjmurphy12:10:56

@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]].

sheluchin12:10:41

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

sheluchin12:10:47

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]]}
  (div
    (li "Card: " suit " " value)))
(def ui-card (comp/factory Card {:keyfn :card/id})) 

sheluchin12:10:40

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

cjmurphy12:10:25

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

cjmurphy12:10:40

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)).

cjmurphy12:10:45

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

cjmurphy12:10:34

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

sheluchin12:10:11

@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?

cjmurphy13:10:18

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

cjmurphy13:10:00

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

cjmurphy13:10:53

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

sheluchin13:10:56

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

cjmurphy13:10:01

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.

sheluchin13:10:53

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.

sheluchin13:10:41

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

simple_smile 4