Fork me on GitHub
#fulcro
<
2017-08-30
>
tony.kay01:08:32

fulcro-sql 0.1.0 released

tony.kay01:08:39

see change log for details

tony.kay01:08:10

“Core Concepts Part 3 – Data Driven” is up on YouTube: https://youtu.be/QsRpZJBhoW4 This shows how a graph-capable library/database (I use the new fulcro-sql in the video) leads to data driven applications. It covers deferred loading and targeted loading, and shows how little code is required to make a server that can respond to diverse client needs.

tony.kay07:08:45

So, the server-side rendering on template had a problem. If you use a browser that doesn’t set a language (accept header) then it dies on logging…because the error call in clj didn’t match it in cljs (my API was inconsistent in the cljc file). This is fixed on the template, but needs beta10-SNAPSHOT of fulcro. Worked fine in Chrome, but I tried it with Safari and Firefox and was surprised by it 😕

denis-v07:08:07

@cjmurphy I haven't figured out how to do a join that uses get-query. Say my Person query is [:db/id :person/name :person/company], and my Company query is [:db/id :company/name]. In the Person query, I guess I could add (om/get-query Company) pull in all the companies? Then I think I need something like {[:company/by-id :person/company] [:company/name]} to get the name of the person's company? But I can't get it to work.

cjmurphy07:08:47

Almost every IQuery will have a get-query or two in it. Only ones that don't are on the edges, where there are no more to-one or to-many relationships to explore.

cjmurphy07:08:13

It is a very old demo, but I like it because it is biggish, and will surely show you lots of relationships - take a look at the Kanban Om Next demo.

denis-v07:08:39

Thanks, I'll take a look

claudiu09:08:51

@denis-v Don't know if this helps. Still figuring stuff out, this is how I do a join with get query. https://gist.github.com/claudiuapetrei/618b433ad4b9476bf99e31bf575ad1cd

claudiu09:08:30

Regarding what you said, my first thought would be when showing the Person, the mutation will look through the state in companies and another key that has the relation between company/person, and put in the :person/by-id {:id {:companies [[:company/by-id 1] [:company/by-id 1]]}}

claudiu09:08:37

might be a better way though 🙂

tony.kay17:08:40

@denis-v the devguide has detailed examples and walkthroughs. The getting started materials also show joins. There are hours of videos on youtube. All of those show this central concept from all different angles.

gardnervickers18:08:10

@tony.kay :elide-asserts true was causing the problem with reads being dropped from the queue. As to why, I have no idea.

tony.kay18:08:27

Anyone wanting to see fulcro-sql in action, you could watch about 2-5 mins of this video starting here: https://youtu.be/QsRpZJBhoW4?t=10m52s

tony.kay18:08:48

@gardnervickers Hm…anytime there is a fix with no “why”, I worry that it isn’t a fix

tony.kay18:08:53

e.g. is it just changing timing to run more asserts? Is there an assertion that is throwing behind the scenes that keeps something from running that is breaking it, which is backwards from the purpose of asserts (an assert throwing shouldn’t cause things to work)

tony.kay18:08:12

@denis-v I just went back and read your original question. I think you’re making it much more complicated than it is.

gardnervickers18:08:15

We had the same bug crop up when doing a load from withing an om/transact! in response to a user event (button press), so it being a timing issue seems less likely. I'm hoping to get a chance this week to get something more minimal to repro with and actually figure out the cause.

gardnervickers18:08:19

Maybe "remedy" is a more appropriate word heh

tony.kay18:08:23

@denis-v the idents are an implementation detail of normalization that you can also choose to query. Querying an ident is a (relatively) rare thing. Normallly, your database will have the relations established in the graph already. So your state from person to company would be something like:

{ :person/by-id { 1 { :db/id 1 :person/company [:company/by-id 99] ...}} ; THE JOIN IS EXPLICIT IN STATE
 :company/by-id { 99 {:db/id 99 :company/name "Acme Corn Huskers" }}

 :current-person [:person/by-id 1]}
and your UI joins would just be:
(defui Company
  static Ident (ident [this props] [:company/by-id (:db/id props)])
  static IQuery (query [this] [:db/id :company/name])
  Object (render [this] ... render company name from props ...))

(defui Person
  static Ident (ident [this props] [:person/by-id (:db/id props)])
  static IQuery (query [this] [:db/id :person/name {:person/company (om/get-query Company)}]) ; JOIN PROPERTY (in state)
  Object (render [this] ... render company using factory on Company and data from :person/company props ...))

(defui Root
  static IQuery (query [this] [{:current-person (om/get-query Person)}]) ; JOIN PROPERTY at ROOT (in state)
  Object (render [this] ... render person using factory on Person and data from :current-person props ...))

driphter19:08:25

@tony.kay How well do you think fulcro would work in an electron app? In the app I'd like to develop, nearly everything would be local, machine-wise, so the remote would likely be IPC calls to the main process for things like preferences, doing work, etc.

wilkerlucio19:08:48

@driphter yes it does, I did some apps with that

wilkerlucio19:08:51

here you can find an example of implementing a custom network using IPC (this example is for a Google Chrome Extension, but the electron version would be very similar)

driphter19:08:35

Awesome, thanks!

wilkerlucio20:08:15

no problem 🙂

wilkerlucio20:08:13

@driphter one thing to notice, on the network there's being a breaking change since I did the last update on this project, so make sure you fix the start signature if you are using the latest fulcro, it doesn't take the app argument anymore