Fork me on GitHub
#fulcro
<
2017-11-16
>
thosmos01:11:41

@roklenarcic when you have multiple components with same ident but different fields, how do you solve that? Is there a way to alias each one like in graphql?

thosmos01:11:54

i suppose with the DB tables, you want all the records in one lookup table, right? but if they have different fields, then do the records in the DB have different sets of fields too?

tony.kay04:11:11

@wilkerlucio @gardnervickers Did either of you submit a bug report? That’s a pretty nefarious little thing

wilkerlucio12:11:14

I'm going to investigate it a little more this weekend, I wanna try make a minimum repro, if I can get a min I'll submit to core.async

tony.kay16:11:19

So, what specifically fixes it? I’ll add it to docs somewhere

wilkerlucio16:11:00

@tony.kay keep elide-asserts compiler option as false, making it true triggers the problem

wilkerlucio16:11:39

I suspect core.async might be relying on some assert to make something work, but needs investigation

tony.kay16:11:06

Yeah, that’s it entirely…there is some side-effecting code (or return value) embedded inside of an assert

tony.kay16:11:27

I’ll update the template project build files and add a comment to that effect

tony.kay04:11:25

@thosmos So, the server-side state has to be constructed to match the state you want the client to be in….but it’s so crazy cool simple: InitiaAppState (cljs = clj!!!) means you can get the initial state for your app as a tree, just like the client-side does. Then, you can use the same optimistic update code (again because you can use cljc for it) to mutate the app into the correct state.

InitialState -> login mutations -> routing mutations -> drop some server-side stuff that would have been loaded in -> state as the app would be on the client.
Then you’ve got a pure renderer that can make it into the HTML you need….super sweet. Note that the template’s SSR code is like 20 lines of logic, and includes login, routing, etc. So, the main task is to make sure your optimistic update code is available as functions from state->state. For example:
(defn do-that-thing* [state args]
  (-> state-map
      (assoc-in [:table id] :blarg args)))

(defmutation do-that-thing [params]
  (action [{:keys [state]}]
    (swap! state do-that-thing* params)))

tony.kay04:11:05

now you can use do-that-thing* in other mutations (when you need to compose things on the client side), and you can use it to evolve server-side state for SSR…

tony.kay04:11:35

The one complication on the server is that union initialization for InitialAppState has to be involved, and you’ll see there’s a helper for building initial state so that you get that right (to-one unions initialized via a tree (of InitialAppState) only have one branch in the tree…so it is the only one that gets normalized in during that first tree->db…but the helper fixes that by scanning the query and components).

tony.kay04:11:25

@roklenarcic @thosmos With regard to same ident/different fields: I assume you’ve got that because they are the same entity, but different UI components want to see different parts of it. If you’re doing anything else, then I’d consider it a design flaw. You should carefully read the Developer’s Guide on Data Merge (subsection Deep Merge) in section H Server Interaction.

tony.kay04:11:05

Same ident should = same exact conceptual (or persistent) entity

tony.kay04:11:34

more than on UI component having the same ident just means different views of the same thing (PersonDetail, PersonView, PersonForm, …)

tony.kay04:11:30

remember that Ident is how auto-normalization works. If you give to things the same ident, then you’ve just indicated to Fulcro to put them in the same database table entry (table and ID). You wouldn’t do that in an SQL database if they weren’t the same thing, would you?

tony.kay04:11:15

@wilkerlucio 🔥 Just pushed the first working mutation join auto-merge demo (in 2.0)!!! The mutation-join-cards (requires you also run the demo server). Note line 12 (remote only mutation) and 18 (a mutation join with query). Clicking the item causes the server to reflect back the return value of the mutation as the tree to merge. So cool. Thanks for the suggestion!

dfornika05:11:25

Can anyone suggest how I can add a js react component to my fulcro project? For example, how can I add one of these data tables to a devcard? https://react-table.js.org/

dfornika05:11:52

if I run 'yarn add react-table' from the project root directory, will it put things in the right place?

claudiu07:11:48

@dfornika Haven't played it js modules, it's on the todolist. From what I know it's not that strait foreword. Fulcro has a semantic-ui wrapper, might have what you're looking for.

tony.kay14:11:38

@dfornika regular React components work fine. This is more of a foreign lib question. See cljsjs and the latest blog posts about using node modules with clojurescript. The links @claudiu sent are relevant for calling them from cljs once you get them working. See also shadow cljs

tony.kay16:11:48

See the STEP comments within. This particular project file pulls in blueprintjs, which does seem to work. Others I’ve tried have not worked…so it depends on the lib in question.

dfornika16:11:25

@tony.kay @claudiu Thanks for the tips. I'm just getting started. I've been wanting to try om.next for a long time but could never quite get off the ground.

tony.kay16:11:11

well, I think you’ll find Fulcro to be easier.You still have to learn the new concepts, but there is much less fiddling to get something real working.

tony.kay16:11:56

is a github version of the blueprintjs thing…I don’t remember what state I left it in, but it did work at one time 🙂

tony.kay16:11:14

I have limited battery at the moment, so I don’t have the power to spare to check it

dfornika16:11:38

Does anyone have a recommendation on the easiest 'data table' component to get started with? I'd just like to load some data into a table with a few features like sorting, filtering and pagination.

tony.kay16:11:08

I would recommend getting started with much simple things

tony.kay16:11:55

Get used to the ideas…if you jump right into something where you have to integrate external components and debug all of that you’re just going to get overwhelmed

dfornika16:11:15

Ok, good advice. I'll spend more time with the intro devcards.

tony.kay16:11:39

First things I’d recommend would be any of these: GettingStarted.adoc in fulcro repo The YouTube videos The Fulcro DevGuide…at least through the server interactions section

tony.kay16:11:52

All three are tuned for the beginner to start

tony.kay16:11:16

The older Untangled videos on YouTube are also useful, including the whiteboard discussion about loading theory. Just replace the word Untangled with Fulcro everywhere you hear it 🙂

tony.kay21:11:28

Fulcro 2.0.0-SNAPSHOT updated. In the past two days I’ve added: - Support for mutation joins (mutations that act as a join key, and indicate an auto-mergeable return value from a mutation) - Support for declaring refresh lists on client mutations (eliminates the need for UI follow-on reads) See the mutation-join-cards and declarative-mutation-refresh in demos for sample code.

tony.kay21:11:17

@wilkerlucio Those sugar helpers are also now present (`returning` and with-params)….so a mutation can now look like this:

(defmutation change-label [{:keys [db/id]}]
  (remote [{:keys [ast state]}]
    (-> ast
      (m/returning state Item)
      (m/with-params {:db/id id}))))

tony.kay21:11:11

Then in the ui one need simply say:

(transact! this `[(change-label {:db/id 1)])

tony.kay21:11:33

and the server can return whatever tree of data makes up Item and it will auto-merge!

tony.kay21:11:19

Of course, you can always hand-code the mutation join at the UI-level…but it looks messy

tony.kay21:11:37

actuallly…my network (hot spotting from my phone) is crappy…snapshot still updating

tony.kay21:11:43

now it’s done

wilkerlucio21:11:06

do you think it's a good time to start trying migration? or still too soon?

tony.kay21:11:53

I’d love early adopters to start trying it. I’m sure there are going to be bugs…but the sooner people start trying it, the sooner we’ll fix em

tony.kay21:11:09

I’ve been hammering a lot on cleaning up some internals as well. I eliminated the plumbing namespace, rewrote the mark/sweep algorithm for data merge. I was pretty well covered by tests on some things, but others like integration behaviors are just really hard to catch.

tony.kay21:11:30

I’d also like to know if any existing larger apps see any performance differences. I suspect since path-opt style rendering is the default it should be faster. There are some cases where I force a root render more aggressively, but the React/shouldComponentUpdate optimizations should make those not noticeable

tony.kay21:11:29

Fortunately, porting should mainly just be the scripted steps the README-fulcro.2.0 doc

tony.kay21:11:47

unless you were depending on some internal functions I’ve removed…in which case I want to know what you were using

tony.kay21:11:06

The new support viewer is written, but untested…got sidetracked

wilkerlucio21:11:27

I'm planning on writing some helper tools over this weekend

wilkerlucio21:11:34

I want to make something like re-trace to fulcro

wilkerlucio21:11:25

the dave conservatoire might take some effort to port, given it uses dynamic queries

wilkerlucio21:11:36

did the interface for dynamic queries changed?

tony.kay21:11:03

so, dynamic queries work a little differently, and you have to implement a different protocol (`dynamic-query`)

wilkerlucio21:11:32

could be a good exercise, but I'll very busy with other things lately

tony.kay21:11:57

basically, dynamic queries are functions of state and ui-factory now. Distinct UI factories give you the critical index

tony.kay21:11:30

and they are strictly stored in state by class/ui-factory-qualifier. This makes history work properly, but does mean you have to add a little code to make them work how you want

tony.kay21:11:59

Helper tools would be nice…you saw the issue with help wanted in Fulcro github?

wilkerlucio21:11:57

looking at it now

wilkerlucio21:11:21

my goal is to have something like this: https://github.com/Day8/re-frame-trace

wilkerlucio21:11:33

that can have a nice view for mutations

wilkerlucio21:11:48

and db watches, seems close to the issue things

wilkerlucio21:11:07

and as an extra, I want a tab to have a history of network activity (queries/resposes)

wilkerlucio21:11:27

yes, I was reading that

tony.kay21:11:28

and the new history recording has a lot of what you’re looking for

tony.kay21:11:02

It records what sends are sent at a step, and the list of active things in-flight updates over time as well

tony.kay21:11:08

(as snapshots in time in the history steps)

tony.kay21:11:29

To me, the table/entity viewer are really most important….well, being able to focus/see/run a component’s query would be nice too

tony.kay21:11:57

anyway…gotta get some lunch. Have fun!

wilkerlucio21:11:04

yeah, I guess OgE can get integrated if we want

tony.kay21:11:35

could be nice