Fork me on GitHub
#fulcro
<
2017-10-06
>
myguidingstar02:10:26

the reason I come up with a junction table is that I can avoid maintaining both book→authors and author→books FK

myguidingstar02:10:02

or is there a sane way to ensure they're in sync?

myguidingstar02:10:31

the thing I'm discussing is what I feel missing from Datascript: :_reverse/lookup (if you don't understand what I mean: http://docs.datomic.com/pull.html#reverse-lookup)

myguidingstar02:10:03

thanks for the link, actually I did the devguide myself

tony.kay03:10:38

@rastandy On your custom types. It sounds like you’re getting them through transit just fine. Fulcro does quite a few things to response data that has to do with ensuring a bunch of things. What you’re trying to do will not be preserved in Fulcro 😞

rastandy13:10:06

Thanks for your clarification. I was going to file a bug report about this but, as far as I understand, custom types preservation is considered something not supported for now. Maybe this could be stated somewhere in the docs, just for people that might struggle with this.

tony.kay03:10:55

The merge logic tries to ensure that multiple requests for the same kind of data in the same query does the right thing over time. For example, say you have one view of something that asks for prop :a, and another that asks for prop :b. Not at the same time.

tony.kay03:10:32

but for the same ident in app state. You don’t want the second (for :b) to clobber the extant app state version of :a (which the other view needs)

tony.kay03:10:52

BUT, if you DID ask for :a and got nothing, you’d want :a to be updated (erased) from app state.

tony.kay03:10:52

So, the plumbing of Fulcro handles this during merge, which means it will re-write map-like things into maps. I have not had anyone to date try to use custom types this way, so I’ve not given any thought to how we might try to preserve the existing (useful) algorithm with custom types.

tony.kay03:10:13

So, I’d have to seconds Mitchel’s advice and recommend you use maps.

tony.kay03:10:21

On another note: I published an update to the semantic UI wrappers on clojars (still 1.0.0-SNAPSHOT). I added ui- prefixes to the factories, because some of them were named unfortunate things like list and comment. The docstrings are now in place in the code (I figured out how to automate the generation of the factories from the docstrings in the js project 🙂

tony.kay04:10:24

@myguidingstar You’re not showing many-to-many…perhaps you mean bidirectional graph edge?

tony.kay05:10:29

First: I’d say “sane way of keeping them up to date”: If your assumption is that a book’s author should always point back at the book: Just make the mutation do that. You never ever do anything too app state except through mutations. If the rule is “If A points to B, then B points to A”, then any mutation that maintains the graph edge must do the work. That said, there’s nothing to keep you from writing a helper function to use in mutations that does the rule application. For that matter, you could make a whole separate processing system stacked on top of your mutations simply by adding a macro (e.g. like defmutation) that wraps your mutations with some other function that enforces various graph rules in a more centralized fashion. Personally, I’ve found it to be quite tractable to just maintain the edges in the mutations, usually with a simple composeable helper, as described in the Reference Guide under “Recommendations about Writing Mutations”

tony.kay05:10:18

I’m open to additional ideas, but automatic maintenance of graph edges and their reverse would mean the addition of schema, and a much heavier (larger, slower, more fragile, etc) database system. That would adversely affect quite a few things in a web client. I agree that it would be “nice”, and I’m open to contributions that at least open up the possibility (e.g. provide hooks to enforce schema? or a hook that auto post-ops on the schema after loads?)

tony.kay05:10:42

I see no way to automate it that isn’t super heavy. Imagine how heavy it would get if you had 20 tables each with 2 edges, and 1000's of objects. Verifying schema after an arbitrary merge could be quite expensive in the general case with a naive implementation, and a clever implementation could be rather hard to get right.

tony.kay05:10:07

so, I’d say I have chosen a “sane” path 🙂

roklenarcic07:10:32

semantic-ui wrapper is an alternative to bootstrap wrapper in fulcro? will advanced opts remove bootstrap if I'm not using it?

rastandy13:10:06

Thanks for your clarification. I was going to file a bug report about this but, as far as I understand, custom types preservation is considered something not supported for now. Maybe this could be stated somewhere in the docs, just for people that might struggle with this.