Fork me on GitHub
#fulcro
<
2018-06-12
>
eric.shao07:06:21

I still want to ask yesterday’s question.

claudiu09:06:20

@eric.shao What is the problem with this state img ? 🙂

claudiu09:06:16

if you're referring to "I want to load one {} or a [] to append to the initial-state’s list.", this one sounds like you should use post-mutation instead of target to implement this custom logic

tony.kay15:06:13

but your first image shows it as a vector

tony.kay15:06:43

Is the return from the server a map that contains the data needed for normalization (ident function on RepaymentItem)?

eric.shao15:06:52

😅 yes, I am not experienced to figure out the problem.

tony.kay15:06:18

wait..the answer to that must be yes, because it did normalize

tony.kay15:06:33

you’re showing 888 in both images

eric.shao15:06:06

the 888 from server is normalized.

tony.kay15:06:24

but your first image already shows it there…so how do you know?

eric.shao15:06:40

so it is in :REPAYMENT-ITEM/by-idx

tony.kay15:06:53

and that came from the server for sure?

eric.shao15:06:49

yes for sure, if I comment the {:fulcro {:started-callback (df/load)} 888 will not show in client.

eric.shao15:06:40

image1 is load from server, just not “target”

tony.kay15:06:38

oh, so your earlier question was “which comes first…“, right? So two are in initial state, and then you run a load in started

tony.kay15:06:01

what is the second image?

eric.shao15:06:05

image2 is load from server and target(df/append), but the 888 ident is still there (not disappearing) and the 1 and 2 ident are turned into nil.

tony.kay15:06:27

so this is out of Inspect? A step by step review of what happened?

eric.shao15:06:57

yes.so I ask which is first. after some console.log I know initialState is first.

tony.kay15:06:21

right, but you’re only issuing one load?

eric.shao15:06:21

ok ,give me a minute.

tony.kay15:06:27

not two, right?

eric.shao15:06:34

just one load

tony.kay15:06:10

it is possible you found a bug…could be initial state and load are not playing right together…but darned if I can see why. Try this just to be sure: Put your load inside of a setTimeout to defer it for a bit:

:started-callback (fn [app] (js/setTimeout (fn [] (df/load …)) 500))

eric.shao15:06:17

It shows slower which is the same as the inspector’s history. First 1 and 2 is showing,then 888 is merged in ,and at the same time the [1 2] turned into nil.

tony.kay15:06:44

any chance you can post the code to github? I can take a look in a bit.

tony.kay16:06:23

@eric.shao I don’t see a problem with your code. I’ll open an issue and track it down.

eric.shao16:06:19

@tony.kay Thank you for your patient.

tony.kay16:06:42

Sorry you hit a bug on such a small attempt 🙂

eric.shao16:06:10

I’m kind of glad. Does that count a contribute?😅 Maybe I will never contribute a thing because of my poor ability.

tony.kay16:06:30

Every little bit helps 🙂

tony.kay17:06:45

@eric.shao workaround…wrap the append to in multiple-targets: (df/multiple-targets (df/append-to ..))

tony.kay17:06:15

as the target…that works. I think perhaps I never tested the standalone append case, but always assumed it would be combined

eric.shao17:06:37

@tony.kay yes , it works!😀

tony.kay17:06:57

so, that’s an easy bug fix as well…thanks for being persistent with your question 🙂

Chris Swanson17:06:25

proofreading contribution - there are two instances of "the the" on http://book.fulcrologic.com

Chris Swanson17:06:05

also first list item under section 4.2.2 - "Fulcro provides a a built-in.."

Chris Swanson17:06:25

are there docs on contributing to the docs?

Chris Swanson17:06:04

another issue - not sure if it's as-designed, but if a component's query function returns a list instead of a vector, it won't validate.

Chris Swanson17:06:10

not really that big a deal, but it wasn't obvious why. doing (reduce conj xs ys ..) instead of (concat xs ys ..) fixed it

Chris Swanson18:06:50

nevermind, looking at the spec i see it's using the list/vector type to determine template/method

tony.kay18:06:34

@chrisjswanson I’d love contributions to the docs…Just fork fulcro’s github repo, and edit DevelopersGuide.adoc, then send a PR.

Chris Swanson18:06:01

right on , will do

tony.kay18:06:15

there is a nice plugin for IntelliJ that will let you preview as you edit, or you can use the Makefile to build the HTML (`make book`)

Chris Swanson18:06:31

cool thanks, i'll check it out

tony.kay18:06:33

output is docs/DevelopersGuilde.html

tony.kay18:06:50

you have to have asciidoctor installed for make, which is ruby-based

tony.kay18:06:39

IntelliJ plugin is just called Asciidoc, and works with the free version

Chris Swanson20:06:14

anyone run into the issue with react where the cursor jumps to the end of an managed input? it prevents inserting text into the middle of a string, for example, because when the value changes it will re-render and the cursor position defaults to the end of the input field

Chris Swanson20:06:07

looks like there may be workarounds to preserve and re-set cursor state before and after an update, but i'm wondering if there is a helper or a "fulcro way" to fix this

Chris Swanson21:06:39

i still see one error for missing main.js , but everything looks fine anyways

tony.kay21:06:06

main is needed if running from figwheel

tony.kay21:06:09

so yes, that is ok

tony.kay22:06:33

@eric.shao So, I figured out the bug. Load has an old option called :marker that historically defaults to “true”, but “true” means overwrite the target value with a load marker. I fixed it to give a warning on the case of special load targets (since the marker would overwrite the original vector), and turn the marker off. So, your original code should work with 2.5.9-SNAPSHOT.

tony.kay22:06:02

Version 2.5.9-SNAPSHOT is on clojars with two load-related bug fixes. One has to do with load splitting/combining, and the other with load markers overwriting to-many relations when the load marker is boolean true (which is the default).