binaryage / cljs-oops

ClojureScript macros for convenient native Javascript object access.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cljs-oops with methods that take arguments

Engelberg opened this issue · comments

What would be the cljs-oops equivalent of:

a.e.f(x).g(y,z);

Is there a better way than:

(ocall (ocall a "e.f" x) "g" y z)

It would be nice to be able to do something similar to Clojure's .. macro, but that doesn't seem to be compatible with cljs-oops's flexible way of handling paths.

Just brainstorming here, maybe it would be possible to support the % character as a placeholder for args, like so:

(ocall a "e.f(%).g" x y z)

I like your idea, but it would take some effort to implement. We would need to support this in both static and dynamic selector case and add some diagnostics in dev mode.

Instead of .. the threading macro -> should do a similar thing:

(-> a
    (ocall "e.f" x)
    (ocall "g" y z))

I've added some tests in 9df72a5 to see if the generated code looks fine.

Yeah, the threading macro definitely helps readability here. Thanks for the suggestion.

Closing because I don't want to add more complexity into "selectors" subsystem. Thanks for the suggestion, though.