untangled

NEW CHANNEL: #fulcro
tony.kay 2016-12-07T00:16:37.000102Z

I've wondered that myself. Obviously, multimethods are not optimal when it comes to doc strings/IDE support, and the fact that they're isolated (as data) from usage site makes it even worse.

tony.kay 2016-12-07T00:17:14.000103Z

My goal would be to find a way to get tools to tell me what mutations were available and how they are used. Can individual multimethod instances have metadata?

tony.kay 2016-12-07T00:17:50.000104Z

actually, your solution of :doc is nice, in that the functions should be side-effect free, meaning you can make a tool to dump the doc that just calls the function

adambros 2016-12-07T00:17:56.000105Z

maybe i should re-ask this in #om ?

tony.kay 2016-12-07T00:18:24.000107Z

It is a valid question for them, yes...and there are 10x the ppl there. Perhaps someone has a suggestion.

tony.kay 2016-12-07T16:21:50.000117Z

@mitchelkuijpers Thanks for the heads up. This might affect us, but it seems primarily an issue with re-rendering. I'll have to look it over mroe carefully.

anmonteiro 2016-12-07T16:27:51.000118Z

@tony.kay in a nutshell, it's basically about not having to re-render from root whenever a remote response is merged in

tony.kay 2016-12-07T17:03:32.000123Z

@anmonteiro A remote response from a mutation? There is no default merge for such a response.

tony.kay 2016-12-07T17:03:57.000124Z

is it just queuing the component that sent the mutation?

anmonteiro 2016-12-07T17:04:09.000125Z

Both from reads and mutations

anmonteiro 2016-12-07T17:04:11.000126Z

And yes

tony.kay 2016-12-07T17:04:19.000127Z

oh, and also the follow-ons

tony.kay 2016-12-07T17:04:25.000128Z

ok, so an optimization

anmonteiro 2016-12-07T17:04:51.000129Z

Yeah

tony.kay 2016-12-07T17:05:03.000130Z

Thanks my friend

anmonteiro 2016-12-07T17:05:03.000131Z

Just to prevent having to re-read root

anmonteiro 2016-12-07T17:05:11.000133Z

Np!

adambros 2016-12-07T19:31:32.000135Z

So the answer from Nolen himself is that there's no obvious answer. I think for now I'll just keep putting the :doc "string" in the return value.

anmonteiro 2016-12-07T19:58:47.000136Z

@adambros: maybe something could be done by messing with the add-method and get-method functions

anmonteiro 2016-12-07T19:58:55.000137Z

Essentially the multimethod API

anmonteiro 2016-12-07T19:59:12.000138Z

But could be fragile and only work for multimethods so I don't know

tony.kay 2016-12-07T20:29:27.000139Z

@adambros Just brainstorming here: I guess you could make real namespaces/methods for the abstract mutation names, which are in turn distributed by the parsing mechanism. Real docstrings could then be used, and the IDE would probably also pick them up. The danger would then be accidentally directly calling them from the UI.

tony.kay 2016-12-07T20:30:56.000140Z

(ns myns)

(defn boo "doc" [env k params] ...)

(ns ui)

(transact! this '[(myns/boo)])

(ns mutations)

(defmethod 'myns/boo [e k p] (myns/boo e k p))

tony.kay 2016-12-07T20:31:31.000141Z

of course, the docstring in this case would be a little weird, in that you would call it differently than the signature of the method indicates.

tony.kay 2016-12-07T20:34:26.000142Z

This is a bit weirder, but you could write the signature as it should be used, then ignore the parameters in the body and instead return a function: (defn boo "doc" [& {:keys [p1 p2]}] (fn [e k p] ...))

tony.kay 2016-12-07T20:35:43.000143Z

then in mutations ns:

(def realboo (myns/boo))

(defmethod 'myns/boo [e k p] (realboo e k p))
something like that...with various clean-ups and removal of boilerplate. E.g. a simple macro for the last step

tony.kay 2016-12-07T20:41:41.000144Z

This has the following advantages: - The IDE doc function works as expected and gives correct information (though you do have to require a namespace that you don't actually use directly) - The implementation adds almost no overhead (in fact you could inline the intermediate realboo) - The IDE jump-to feature actually jumps you to the correct code that really accomplishes the task

tony.kay 2016-12-07T20:41:58.000145Z

so, basically, it acts just like a regular function, while being "just data" from the UI

tony.kay 2016-12-07T20:43:19.000146Z

A macro potentially loses some of those benefits (e.g. if you generate all of that from a single macro the IDE might lose the ability to jump to the definition). Worth trying in NREPL and Cursive and see.