Fork me on GitHub
#fulcro
<
2020-01-21
>
tony.kay03:01:07

@thomas (-> env (uism/load …))

tony.kay03:01:24

or load-actor

tony.kay03:01:10

By design you are supposed to set actors at the start of the state machine. Presumably your list of data would be one of the actors, with a known ident

tony.kay03:01:29

the UISM ns has functions for pulling the actor class, ident, etc.

otwieracz14:01:10

How would you gauge adoption of Fulcro?

otwieracz14:01:53

I see this is very interesting technology, but how does it compare to for example Reagent and Reframe? How popular it is, how many users it have?

henrik16:01:50

It’s most likely wildly misleading in either direction, but you could look at the number of participants in this channel. I’m curious, what do you plan on doing with this information if you manage to find it out?

otwieracz16:01:28

I am just considering which technology to learn.

otwieracz14:01:05

Are there any direct alternatives to Fulcro?

tony.kay15:01:28

@slawek098 How many people adopted Angular 1? Did it matter?

tony.kay15:01:39

pls have that discussion elsewhere 🙂

tony.kay15:01:55

If you have a technical question about the appropriateness to a task, it is welcome…popularity contests are a misuse of my time and others. Real businesses use it for real things.

tony.kay15:01:57

See subject line for a list of resources to use in evaluation.

otwieracz16:01:18

@tony.kay Sorry if you felt offended - I really appreciate enormous amount of work you've put into Fulcro and I haven't seen anything like that in Clojure - and that's why I was curious how popular it is, because by completeness of this project, number of commits etc I'd expect it to be super popular and kind of "go-to solution".

tony.kay16:01:39

not offended

otwieracz16:01:47

OK. Sorry again!

tony.kay16:01:43

no worries…my point is that generic comparisons are difficult, and popularity is not a good indicator of what you probably care about.

tony.kay16:01:19

you can adopt the most popular thing on the planet and be hosed a year later

otwieracz16:01:32

Yes, but it does matter when you are looking for job - I've seen offer asking specifically for Fulcro skill.

tony.kay16:01:44

and Fulcro is not trying to address the same things as Reagent/reframe (which are only concerned with front-end)

otwieracz16:01:01

Yes, that's what I like in Fulcro!

tony.kay16:01:05

if you’re looking for a job, stick to vanilla js 😜

otwieracz16:01:18

Not having to connect 10 separate components for simple project.

otwieracz16:01:26

Just to PoC something quickly.

tony.kay16:01:58

yeah, if you know Fulcro well then that is a great thing about it…many ppl would disagree with you though, saying they rather PoC with Reagent or Rum. To each their own. Simple vs easy vs appropriate-for-the-job.

tony.kay16:01:24

but some simple research will get you numbers from Clojars: • rum 110,000 downloads (lifetime) • re-frame 800,000 downloads (lifetime) • js Redux 3.8 MILLION a WEEK • Fulcro 28,000 of v2.x, 4,000 downloads of 3.x (lifetime)

tony.kay16:01:06

we’re in clojure-land…our popularity is very very very low. Of the items in clojure-land, Fulcro is less than 1/10th as popular as others.

tony.kay16:01:45

probably 3x harder to learn (not to discourage you, just reality: Fulcro has more parts…in the long run I think it is much much easier to use on commercial-size projects)

wilkerlucio17:01:34

@slawek098 on the learn side, one interesting thing to consider is that by learning fulcro you will learn a production tested UI data model, even if you don't use fulcro that's a very good trick to have internalized, this is something I didn't see any other React library do (considering all normalization, server integration, etc...)

💯 20
maxt18:01:59

I'm trying to load updates but I'm having a hard time convincing Fulcro to merge my to-many edges instead of replacing them. I've tried using :append-to, but that will create duplicates when given a list. I've tried using pre-merge to reappend the previous edges, but that makes the mark-missing function fail. My current idea is to load it with a temporary target and have a separate merge post-mutation. Is there a simpler way?

wilkerlucio19:01:59

one way is to use a :target to initially merge the results in a separated part of the db, them use a post-mutation to assemble the data in any way you want

maxt20:01:10

Yes, makes sense, but I ran into problems with that too, because only the entity itself is placed at the separate target, it's contents are normalized and therefore overwrites existing entities.

maxt20:01:29

So I have a Company with Employees, and to a parameter that says I only want entites that are newer than the given transaction id. I'd like to load it with a query like

(df/load! this [:company/id 10] Company
          {:params {:since-tx 13194139533344}})
Which gives me a response like
{[:company/id 10]
 {:company/employees [{:employee/id   200
                       :employee/name "Foo"}]}}
And I cant figure out how to merge the list of employees with whats already there.

thosmos23:01:12

Is there an Employee defsc with an ident? If so, does company/employees wind up as a vector of edges? Are you saying you want to merge the new vector of edges with the existing vector of edges for the given company? Like

(merge 
  {:company/employees [[:employee/id 200] [:employee/id 201] [:employee/id 202]]} 
  {:company/employees [[:employee/id 300] [:employee/id 301] [:employee/id 302]]})
And you’re finding you now just have employees 300,301,301 instead of 200,201,202,300,301,302?

maxt01:01:35

Yes, that's what I'm saying. In your example something like

(merge-with (comp vec concat)
            {:company/employees [[:employee/id 200] [:employee/id 201] [:employee/id 202]]}
            {:company/employees [[:employee/id 300] [:employee/id 301] [:employee/id 302]]})

maxt01:01:11

The closest I've got is using append-to like this:

(df/load! this :all-employees Person
          {:params {:target   (targeting/append-to [:company/id 10 :company/employees])
                    :since-tx 13194139533344}})
But then I don't know how to just get the employees of company with id 10. And append-to, with to-many edges, does not remove duplicates. And I need to repeat the logic for company/customers etc.

thosmos01:01:22

I’m not aware of any Fulcro helper for this particular need, but that doesn’t mean there isn’t a better way than what I know. The way I would do it is to set :target to something like [:company/id 10 :ui/temp-emps] and then have a :post-mutation that does the merge manually.

thosmos01:01:08

I’m curious why you don’t want to just replace the employees vector if you’re getting :all-employees ?

thosmos01:01:03

where are the other edges from?

wilkerlucio01:01:07

@U0773UB6D gotcha, because or normalization you get the data merged and lost, one way around it is to trigger the load with a query without normalization, if you do that them you will get it merged as raw, giving you control, you modify that and merge again with merge-component in case you have some complex data to normalize

thosmos01:01:04

I guess I’m unclear what exactly is getting lost during the merge?

thosmos01:01:11

I do something similar and it works without losing data even if I do a load with a subcomponent that only has one key in the query, it merges into existing tables and keeps the existing data.

thosmos01:01:00

@U0773UB6D what do :ident and :query look like on your Comp and Emp classes?

maxt02:01:28

@U066U8JQJ right, I'm currently trying to use my own :ok-action to override the default merge behavior. Using merge-component on the parts to get some of the functionality back might be a good idea. Thanks! @U07KXN95L The "other edges" are an update, they are employees that got added after the first load was made. The :since-tx params tell the resolver to not really return all employees, but only those that are new.

thosmos02:01:46

I see yeah I would probably do the second query :all-employees because it makes it more clear that your :since-tx param is only referring to new employees, and also add a :company-id 10 arg to the params. then target a temp variable and do the merge manually, finally deleting the temp state. So something like:

(df/load! this :all-employees Person
          {:params {:target [:company/id 10 :ui/new-employees] :since-tx 13194139533344 :company-id 10 :post-mutation `merge-emps :post-mutation-params {:from [:company/id 10 :ui/new-employees] :to [:company/id 10 :company/employees]}}})

👍 4