Fork me on GitHub

In Clojure/Java, there are functions extenders and extends? in clojure.core that can in some cases let one know whether an object or type/class extends a particular given protocol. These do not exist in Clojurescript, at least not by those names. This is not high priority by any means, but is there perhaps data that one can peek/poke/prod at at a Node.js REPL (or some other JS runtime REPL) that let you discover that information in a running system?


I don't know. I can try it out and see what it does.


I know one can examine the ClojureScript source code, of course. I was curious if there was a more dynamic way to do it, like there is in Clojure/Java.


@andy.fingerhut not quite sure what you are asking. there is (satisfies? SomeProtocol foo) or (implements? SomeProtocol foo)?


Hi. Can someone help with AWS sdk response from nodes,js aws-sdk. I would like to return in aws labmda cljs function I am getting an [Object etc] as a response which I cannot seem to be able to pass it to the lambda handler callback, (if I print it, I can see the data). The AWS SDK node.js documentation suggest using a promise var bucketPromise = new AWS.S3({apiVersion: '2006-03-01'}).createBucket({Bucket: bucketName}).promise(); Promise would work for me. How can I achieve this in cljs? And is the the best way to handle it?


@dennisa something like this

(ns myns.core
   ["aws-sdk" :as AWS])

(def s3 (new AWS/S3))

(-> s3 
  (.createBucket #js{:Bucket "blabla"})


Threaded expression will return a promise that you can return from the lambda handler function


You can either return a promise from the lambda handler, or call the callback function. If you want to do the latter you can do something like

(-> s3 
  (.createBucket #js{:Bucket "blabla"})
  (.then callback))


Where callback is the Lambda callback function


Here’s a small example project where I’m using node aws-sdk with lambda


@valtteri This is exactly what I was looking for, this works fine when is invoke the function locally:

(-> my-s3-client
                   (.then (fn [res]
                            (print res)
                            (clj->js res)))))


Do you perhaps know how to return a value from a chan into aws lambda callback in cljs? This is puzzling me because go block is returning a channel and breaks lambda. Perhaps some trick with take! ?


not sure if I understand it correctly, but typically you want to convert callbacks to core-async channels, the idea is to return a channel and do put! in callback body (to convert callback call into a new item on channel)


btw. promise-chan is better thatn general chan because you know it will be just one-off callback


Sorry I’m not using core.async in lambdas, just Promises.

thanks2 4

@darwin The callback I am talking about is the AWS lambda callback mechanism in the handler. I can either return a promise in the handler (which is covered by example above) or call the callback, which should return the final result. When I call callback in take! it looks like the handler fails on no value:

(.listBuckets my-s3-client    #(put-in-chan ch %2 :Buckets))
  (defn handler [event context callback]
  (take! ch #(callback nil #js{:statusCode 200
                               :headers #js{"Access-Control-Allow-Origin" "*"
                                            :Content-Type "text/html"}
                               :body (str %)})))


Anyone have any successful usage of material-ui/pickers and date-io/moment in their stuff? Currently attempting to use these by importing like

["@material-ui/pickers" :refer [DatePicker MuiPickersUtilsProvider]]
["@date-io/moment" :default MomentUtils]
and it seems that the import of DatePicker and MuiPickersUtilsProvider work, but my import of MomentUtils seems to be undefined when I try to use it. Any ideas on stuff to try?


@shanelester55 try this ["@date-io/moment" :as MomentUtils]


Ha. now it works perfect. Thank you @valtteri


No problem!


I've got Pathom related question. I am trying to create global resolver, but by some reason I am constantly getting not found response. First, I have wire-list . Take this sample query:

[{[:wire-list/id :my-wires] [:wire-list/id :wire-list/wires]}]
it return:
{[:wire-list/id :my-wires]
 {:wire-list/id :my-wires,
  :wire-list/wires [{:wire/id 0} {:wire/id 1}]}}
as expected. However, when I try to use resolver:
(defresolver wires-resolvers [_env _input]
  {::pc/output [{:wires [:wire-list/id]}]}
  {:wires {:wire-list/id :my-wires}})
[{:wires [:wire-list/id]}]
I am getting:
{:wires {}}
in response


What am I doing wrong?


in (def foo x/bar) is there an easy way to have x/bar's metadata on foo? Have a util namespace for some components and this would be quite a nice usability improvement


depends what you mean by easy I guess. (alter-meta! #'foo merge (meta #'x/bar)) directly after isn't super hard, but it's definitely not nothing


not available to anything indexing the codebase statically too


yeah. any of this would fail clojure-lsp usage so its a no-go for my vim/clojure-lsp bound coworkers


In this case, making the LSP understand alter-meta! is probably the only way .