Skip to content

bean :recursive true and ->clj behaves differently #76

Open
@torbjornvatn

Description

When I try to interact with the objects returned by the Google Cloud getProjects function I get different results when using ->clj and bean :recursive true

(p/let [[ps] (.getProjects resource #js {:filter "name:uc*"})]
    (->> ps
         (map #(bean % :recursive true)
         first
         cljs.pprint/pprint)))
;; =>
{:metadata
 {:projectNumber "XXXXXXXX",
  :projectId "XXXXX",
  :lifecycleState "ACTIVE",
  :name "XXXXX",
  :createTime "2019-11-28T09:56:03.185Z",
  :parent {:type "folder", :id "1004516592721"}},
 :baseUrl "/projects",
 :parent #object[Resource [object Object]],
 :id "XXXXX",
 :createMethod #object[bound wrapper],
 :methods
 {:create true,
  :delete true,
  :exists true,
  :get true,
  :getMetadata true,
  :setMetadata {:reqOpts {:method "PUT"}}},
 :interceptors [],
 :Promise #object[Promise],
 :restore #object[wrapper],
 :create #object[wrapper],
 :delete #object[wrapper],
 :exists #object[wrapper],
 :get #object[wrapper],
 :getMetadata #object[wrapper],
 :setMetadata #object[wrapper],
 :request_ #object[Function],
 :request #object[wrapper], 
 :requestStream #object[Function]}

vs.

(p/let [[ps] (.getProjects resource #js {:filter "name:uc*"})]
    (->> ps
         (map ->clj)
         first
         cljs.pprint/pprint)))
;; =>
#object[Project [object Object]]

Is this because the objects returned from the Google Cloud library is not "pure" javascript Objects?

I would love to add something to the README about this gotcha, but not sure how to formulate it as I don't really understand the underlying reason for this happening.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions