domino-clj

mafcocinco 2019-11-06T03:19:52.002200Z

@yogthos are pre and post conditions going to be the mechanism by which we can conditionally fire some events but not others based on the result of a handler? The likely have other uses as well, but just wanted to confirm.

yogthos 2019-11-06T03:22:13.003400Z

yeah what I was thinking was that you could put :pre and :post keys in the options map on the path segment, then those would be injected in each event that takes the segment as its input

yogthos 2019-11-06T03:23:00.004500Z

and I'm thinking the pre/post can return either the output that gets persisted in the state, or an error

yogthos 2019-11-06T03:23:26.005300Z

actually maybe it can return a map with a dispatch key that could be used in a multimethod

yogthos 2019-11-06T03:23:39.005900Z

so the default would be to persist the output, and then you could define custom ones to do whatever

mafcocinco 2019-11-06T03:23:55.006100Z

Funny, that is just what I was going to say. 😉

yogthos 2019-11-06T03:24:04.006500Z

excellent 🙂

mafcocinco 2019-11-06T03:24:24.007400Z

I saw your doc changes to indicate taking a map on inputs and outputs. Are you going to change the result of the handler to return a map with named values as well?

yogthos 2019-11-06T03:24:27.007500Z

sounds like we have a plan

yogthos 2019-11-06T03:24:35.007700Z

yup

mafcocinco 2019-11-06T03:24:40.008Z

cool.

yogthos 2019-11-06T03:24:42.008100Z

should already be done in the change

yogthos 2019-11-06T03:24:50.008300Z

just need to clean up the docs

mafcocinco 2019-11-06T03:24:57.008700Z

sweet.

yogthos 2019-11-06T03:25:19.009200Z

and the resolution logic there is to go by the keys the handler explicitly returns and only modify those

yogthos 2019-11-06T03:25:36.009700Z

so if it an output is declared but it's not in the output map, then it will be left alone

yogthos 2019-11-06T03:25:54.010100Z

and clearing an output requires putting the key with a nil value

mafcocinco 2019-11-06T03:26:50.010600Z

yeah, that makes sense. But clearing would not fire the event correct? Just remove it from the db?

mafcocinco 2019-11-06T03:27:41.011Z

and presumably if the output key is not present, no event will fire either.

yogthos 2019-11-06T04:01:38.011400Z

yup

yogthos 2019-11-06T04:02:29.012200Z

basically the idea is that the handler explicitly declares what of its output keys it's changing

mafcocinco 2019-11-06T11:10:07.000200Z

:thumbsup_all:

mafcocinco 2019-11-06T15:17:12.005800Z

Given this model

mafcocinco 2019-11-06T15:17:40.006100Z

And this transaction

mafcocinco 2019-11-06T15:20:45.009200Z

Should one expect the event to fire? I would say yes but that is currently not the case. This is the other side of the coin WRT to firing parent events. Put another way, would we want to attempt to translate the above transaction into (domino/transact @ctx [[[:parent :child] 2]])? Certainly adds complexity and I'm not 💯 that there exists a mechanical transformation vs. one where domino would need to make decisions/assumptions.

carmen 2019-11-06T15:27:45.009500Z

I can see use cases for both behaviours

mafcocinco 2019-11-06T15:30:00.011500Z

I have been using re-frame as a mental model and re-frame's answer to this is yes. However, we are not obligated to follow the way re-frame works. This is definitely more complex than the other change which made the parent sub-paths fire, as in this case, the model can be arbitrarily complex. However, it should not be too difficult to write a function which simply returns all of the necessary paths (child and parent), given the original input and the model.

mafcocinco 2019-11-06T15:36:51.012100Z

And I take that back, there probably is a mechanical transformation.

yogthos 2019-11-06T16:14:43.013900Z

I'm leaning towards yes on this one since the input value for :c changed, and events should be firing whenever their inputs are updated

nikp 2019-11-06T16:21:40.016Z

Hm, same re yes, but I'm hesitant to be firm due to other possible data collections. Or even do we want to support lose models where you can have nested maps that aren't speced out? Depends how opinionated we'd want to make it

nikp 2019-11-06T16:21:50.016400Z

Maybe value in having it as a separate module?

nikp 2019-11-06T16:23:47.018Z

+ I'm very much in favour of keeping core lib lean/just the execution engine, and add additional functionality as separate modular libs. A la reitit

mafcocinco 2019-11-06T16:34:26.019100Z

I think we should maintain data that is passed in, even if it is not spec'ed out in the model. That, IMO, is in the spirit of Clojure more broadly. That is, pass along what you don't care about, use/validate what you do care about (and pass that along too).

mafcocinco 2019-11-06T16:36:09.021Z

So, in the above example, if the user ran this transaction: (domino/transact ctx [[[:parent] {:child 1 :other-child 2}]]), we could translate it to a transaction that looked like this: (domino/transact ctx [[[:parent] {:other-child 2}] [[:parent :child] 1]]). I think that works.

mafcocinco 2019-11-06T16:36:26.021300Z

At least, I got the expected results when I ran it by hand.

mafcocinco 2019-11-06T16:37:10.021700Z

The db then would contain {:parent {:child 1 :other-child 2}}

mafcocinco 2019-11-06T16:38:07.022400Z

And, IIUC, the redundent [:parent] path triggering would be pruned due to the use of a set.

mafcocinco 2019-11-06T16:39:11.023300Z

WRT implementing it as a separate module, I'm indifferent to that. If others feel strongly about it one way or the other, I'm totally cool.