Fork me on GitHub
#keechma
<
2017-08-05
>
urbank14:08:38

@mihaelkonjevic IMO it would be nice to have a less opinionated merge logic for dataprovider apart from the :target field. It is elegant, and perhaps should be used most of the time, but perhaps there should be an option to provide a custom function which takes the current app-db and the fetched data and merges the fetched data into the app-db.

mihaelkonjevic14:08:49

So, params fb gets it's dependencies data and it's previous value. This allows you to implement things like infinite scroll, where you append to collection all the time. Also, the loader fan gets full access to app-dub, so you can get the data you need there. It was important that params fn has no free access to app do so I can manage the dependency graph

mihaelkonjevic14:08:30

Here you can see that API loader fn can accept a function that can be used to load the data from the app db instead of doing the http call

mihaelkonjevic14:08:43

And yes clojure 1.9 and previous version of clojurescript work with keechma. Only the latest release causes issues (in the toolbox lib)

urbank14:08:56

Ah, I see. I thought that I was probably missing something. I'll check out that code again.

mihaelkonjevic14:08:13

Oh and another thing, if you have some special use cases you can still manually manage some parts of your app db, and depend on them from dataloader. Checkout this https://github.com/gothinkster/clojurescript-keechma-realworld-example-app/blob/master/src/cljs/realworld/datasources.cljs#L46

mihaelkonjevic14:08:00

Jwt data source is ignored when the data is in app db. When it's not it tries to load the jwt from the local storage

mihaelkonjevic14:08:26

actually scratch that, wrong example

mihaelkonjevic14:08:03

this is the correct one:

mihaelkonjevic14:08:18

so in this case access token datasource has the same strategy

mihaelkonjevic14:08:41

tries to load it from the local storage if it exists, but it doesn’t reload it if it’s already in the app-db

mihaelkonjevic14:08:09

there is a moment when user enters the access token, and we need to re-trigger the data loader

mihaelkonjevic14:08:21

that happens here

mihaelkonjevic14:08:44

(these is using the new forms library, but important to know is that this is basically the controller code)

mihaelkonjevic14:08:09

so, you can manually tell data loader to re load it’s datasources

mihaelkonjevic14:08:00

so if you have a special data source that has some convoluted logic, you can implement it in a controller, and still use the data loader for the rest of the app

urbank14:08:06

👌 Thanks!