Fork me on GitHub
#asami
<
2021-04-02
>
indy07:04:17

Couldn't find something like a https://github.com/tonsky/datascript/blob/eb8ba4cd7217640b282a25ca2adda93183a9a4cf/src/datascript/core.cljc#L564 in Asami, the datascript implementation looks straightforward. I'm planning to use Asami with re-frame in the browser and kind of require this. Is this something word adding to Asami?

indy07:04:00

I might be wrong but I think Asami's query optimizer might really shine with re-frame, since on every single transact (any state change of the app-db), all http://day8.github.io/re-frame/subscriptions/#why-layer-2-extractors will run and query the db.

ribelo07:04:18

the problem with asami is that it is designed for reading, not writing. transactions are deadly slow

ribelo07:04:58

it could rather be alongside db in re-frame, but not really as a replacement

ribelo07:04:45

then there is no need to refresh the views in case of transactions, because it is better not to do too many transactions. Even if you would like to, the time saved by the planner will be wasted

indy08:04:05

Oh okay, didn't know that Asami is designed primarily for reading. Thanks 👍:skin-tone-4:

ribelo08:04:16

It all depends on what kind of data you have and how fast it changes

ribelo08:04:07

adding 20k entities to asami takes 2500ms where datascript needs 1500ms

ribelo08:04:08

If you need to retrieve data from BE and display it to the user using complex queries, then asami is much better than anything else.

indy08:04:08

I wanted asami to replace the global atom in re-frame. Which means it would be transacted upon on almost every kind of user interaction. Maybe a max of 30 transactions per second (naive figure after checking my redux dev tools for how many max actions are usually dispatched per user interaction)

ribelo08:04:31

if you want to keep a small amount of data that you operate on frequently, I recommend that you see how fulcro does it. There is a lot going on around this topic, a solution you can use in re-frame is autonormal

indy08:04:21

Great, my main intention was to keep the app db normalized, and the autonormal library might be what I am looking for

ribelo08:04:30

pull syntax/`eql` does not give you the same power as datalog, but it is usually sufficient

ribelo08:04:17

if you already have a normalized DB that is as flat as possible, a good solution for more complex queries is a meander

indy08:04:39

Yeah, I've dabbled with fulcro, kind of liked how the component was "hooked" to the app db using the EQL graph query, but felt the API surface layer was too big and the code didn't feel "neat"

ribelo08:04:55

I also much prefer the re-frame, and have made many approaches to fulcro in my spare time. it's big and clunky, but solves many problems.

ribelo08:04:42

here you can find an example how to mimic datascript using meander

indy08:04:18

(reading through meander's README)

ribelo08:04:25

I have to go

ribelo08:04:31

good luck!

indy08:04:45

Thanks a lot ribelo, that was of great help!