keechma

Keechma stack. Mention @U050986L9 or @U2J1PHYNM if you have any questions
urbank 2017-08-10T10:08:30.908491Z

@mihaelkonjevic In the new forms library, can only one form be active at a time for a given key in the map passed to keechma.toolbox.forms.controller/regiester ?

urbank 2017-08-10T10:09:03.918967Z

oh nwm

urbank 2017-08-10T10:09:32.928837Z

the second part of the tuple is determined by the forms-params function, right?

mihaelkonjevic 2017-08-10T10:29:58.320607Z

yes, so there are two parts

mihaelkonjevic 2017-08-10T10:30:01.321586Z

1. form-type

mihaelkonjevic 2017-08-10T10:30:03.322157Z

2. form-id

mihaelkonjevic 2017-08-10T10:30:15.326294Z

so you can have multiple forms of the same type active at the same time

mihaelkonjevic 2017-08-10T10:30:46.336965Z

form id is usually either :new or id of the entity you’re editing

mihaelkonjevic 2017-08-10T10:31:42.354542Z

there is a convenience form mount controller that can automatically mount forms https://github.com/keechma/keechma-toolbox/blob/master/src/cljs/keechma/toolbox/forms/mount_controller.cljs

mihaelkonjevic 2017-08-10T10:32:27.368907Z

but you can also manually mount forms if needed

urbank 2017-08-10T10:35:10.420210Z

Cool. The example apps are very useful for figuring out how it fits together

urbank 2017-08-10T11:30:42.424311Z

Hm... so with the newest version of clojurescript keechma$controller$IController$execute$arity$3 is called in the compiled javascript for the pipeline controller. But with an older version (1.9.229) keechma$controller$IController$execute$arity$3 is never called, only defined in the keechma/controller.js file.

mihaelkonjevic 2017-08-10T11:31:45.443580Z

what’s weird is that it has arity 3 defined https://github.com/keechma/keechma/blob/master/src/keechma/controller.cljs#L80

urbank 2017-08-10T11:32:15.452671Z

Yeah, I saw that.

urbank 2017-08-10T11:37:43.552260Z

But surely execute has to be called at some point in the working version, right? Can't find any call sites in the compiled javascript though.

urbank 2017-08-10T11:39:40.586817Z

Hm... no that was a shot in the dark. It does get called, obviously. If I add console.log there it prints

mihaelkonjevic 2017-08-10T12:27:43.536330Z

well this is crazy

mihaelkonjevic 2017-08-10T12:27:54.540277Z

this form works (apply controller/execute [this :start params])

mihaelkonjevic 2017-08-10T12:33:31.667310Z

this also (let [e (partial controller/execute this :start params)] (e))

mihaelkonjevic 2017-08-10T12:38:22.780790Z

this one also works lol ((partial controller/execute) this :start params)

urbank 2017-08-10T13:57:18.157571Z

@mihaelkonjevic Ha!

urbank 2017-08-10T13:58:19.195039Z

Does this mean it's likely that this is a compiler bug ?

urbank 2017-08-10T14:01:19.309866Z

But wait... partial with no arguments literally just returns the function!

urbank 2017-08-10T14:01:35.319747Z

(defn partial ([f] f))

mihaelkonjevic 2017-08-10T14:02:13.343420Z

it’s a mistery 🙂

mihaelkonjevic 2017-08-10T14:02:35.357825Z

I’m downgrading cljs version by version atm to figure out which version introduced this

urbank 2017-08-10T14:02:59.373099Z

Cool :thumbsup:

urbank 2017-08-10T14:03:21.385894Z

So if partial with not arguments works so should just plain identity, right?

urbank 2017-08-10T14:11:26.678748Z

@mihaelkonjevic So it seems that with the pipeline controller the partial thing works. However with the dataloader controller and the forms-mount-controller I get

urbank 2017-08-10T14:11:27.679833Z

this$__$1.keechma$controller$IController$execute$arity$2 is not a function

urbank 2017-08-10T14:11:45.690496Z

so arity2 not 3

mihaelkonjevic 2017-08-10T14:11:48.691970Z

it seems that cljs 1.9.456 introduced this behavior

mihaelkonjevic 2017-08-10T14:12:02.700515Z

I’ll try to figure out what did it

👍 1
urbank 2017-08-10T14:17:20.896498Z

Wonder why arity 2 doesn't behave the same. Adding an empty parameter to the dataloader controller's execute method and applying partial to execute works too

urbank 2017-08-10T18:22:54.966223Z

@mihaelkonjevic hm, why does key-to-path strip namespace from the keyword

mihaelkonjevic 2017-08-10T18:25:58.075402Z

@urbank it's using name fn which does it. Name is used to get string from keyword, but there was no intention to remove the ns too

urbank 2017-08-10T18:29:55.214401Z

I see. I'm using namespaced keywords for most of the fields of various entities. For example, the 'on-change' helper from keechma.toolbox.forms.helpers/make-component-helpersuses the key-to-path function, so a form with a field like :person/name doesn't update

urbank 2017-08-10T18:31:48.281253Z

Oh, if a pass it in as a vector, it should work I suppose

mihaelkonjevic 2017-08-10T18:32:18.299057Z

Ah, ok I'll push the fix out

mihaelkonjevic 2017-08-10T18:32:57.321395Z

I'm not sure what to do with the arity errors though

mihaelkonjevic 2017-08-10T18:33:27.337762Z

I could fix them in keechma and toolbox by wrapping fns in identity

mihaelkonjevic 2017-08-10T18:34:25.372050Z

It feels dirty but it would also allow new cljs version which has nice npm integration

urbank 2017-08-10T18:35:09.397655Z

Does feel a bit dirty. But IMHO the benefit outweighs it 🙂

urbank 2017-08-10T18:35:24.406693Z

however a custom controller would also need to do this, correct?

mihaelkonjevic 2017-08-10T18:37:43.486304Z

Yes but I'd add it to readme. I'm. It sure how much would it affect people

mihaelkonjevic 2017-08-10T18:38:22.508183Z

It only happens when you call on overriden protocol method from the overriden one

mihaelkonjevic 2017-08-10T18:38:46.521948Z

So I think that all pipeline based code is safe

urbank 2017-08-10T18:40:22.575765Z

Did you also see the arity 2 error for dataloader and mount-form controllers?

mihaelkonjevic 2017-08-10T18:41:49.624577Z

Yeah, all caused by the same issue

mihaelkonjevic 2017-08-10T18:42:25.645183Z

My first hunch was that its multi arity related

mihaelkonjevic 2017-08-10T18:42:29.647687Z

But it was wrong

urbank 2017-08-10T18:46:37.787367Z

So it's a bug in clojurescript?

mihaelkonjevic 2017-08-10T18:47:28.816204Z

I guess

mihaelkonjevic 2017-08-10T18:47:43.824583Z

But I couldn't find the commit that caused it

mihaelkonjevic 2017-08-10T18:48:14.842244Z

I've asked on #clojurescript channel

mihaelkonjevic 2017-08-10T18:48:23.847553Z

Hopefully someone will answer

urbank 2017-08-10T18:49:56.901289Z

Oh, cool, a minimal example. I'm sure someone will know what's going on.

mihaelkonjevic 2017-08-10T20:00:40.191270Z

heh, I sure hope that the new behaviour is not the intended one, I’ll have to rewrite the controller if it is 🙂

mihaelkonjevic 2017-08-10T20:12:17.566706Z

well, there it is https://github.com/keechma/keechma/issues/30

urbank 2017-08-10T20:18:19.751131Z

@mihaelkonjevic 🙁 Oh well. So are you thinking of a macro where it puts the default implementations for the unimplmented methods?

mihaelkonjevic 2017-08-10T20:19:31.788146Z

yeah

mihaelkonjevic 2017-08-10T20:19:45.794875Z

I like how the current API feels

👍 1
urbank 2017-08-10T20:23:48.920723Z

Wonder why partially implemented protocols aren't supported

urbank 2017-08-10T20:25:51.985174Z

Protocol is somewhat like typeclass in haskell, right? There default implementations of "methods" still work if you implement some of the "methods"

mihaelkonjevic 2017-08-10T20:26:29.005656Z

yeah, that’s what I was expecting too

mihaelkonjevic 2017-08-10T20:31:06.155066Z

one other option is to split methods, so there’s only one per protocol. We would have IControllerExecute, IControllerHandler etc, but that seems verbose

urbank 2017-08-10T20:32:53.212418Z

I don't have the foresight to have an opinion on what would be better 🙂

mihaelkonjevic 2017-08-10T21:14:06.482862Z

@urbank what do you think about multimethods? I think this might be the solution and the API would be similar

mihaelkonjevic 2017-08-10T21:14:41.498071Z

they support default implementation, so most of the API would be similar

urbank 2017-08-10T21:20:49.665272Z

@mihaelkonjevic Hm... right multimethods! Seems good to me. Perhaps it's a bit less "in one place" if that makes sense, but otherwise seems fine. Multimethods are supposed to be somewhat slower, but I suppose that shouldn't be an issue for this use-case. I'll think about it for a bit and tell you my thoughts for what they're worth. Can't think of much right now 🙂

mihaelkonjevic 2017-08-10T21:24:03.751469Z

yeah, I understand what you mean with “less in one place”. But the most important (at least to me) part is the ability to have a default implementation so you don’t have to implement everything just to satisfy the form.

urbank 2017-08-10T21:28:09.859782Z

Yeah, I think that's definitely much more important. "Less in one place" is mostly just aesthetics, and maybe it's because I got used to this. Plus, emacs (parinfer/edit not sure) indents my protocol implementations a bit weirdly anyway 😆

mihaelkonjevic 2017-08-10T22:38:42.420633Z

@urbank keechma 0.3.0-SNAPSHOT-1 is out. Controllers are rewritten to use multimethods, updated to latest reagent, latest (stable) react (15.6) and latest ClojureScript

mihaelkonjevic 2017-08-10T22:39:19.431772Z

it wasn’t that horrible. all controller changes are mechanical, function bodies are almost identical

mihaelkonjevic 2017-08-10T22:40:11.447406Z

also, I’ve pushed my forked version of cljs-react-test (https://clojars.org/org.clojars.mihaelkonjevic/cljs-react-test) if you need it. It’s updated to latest react too

mihaelkonjevic 2017-08-10T22:42:31.487653Z

I’ll update the toolbox lib tomorrow or over the weekend