Liking cljdoc? Tell your friends :D

Migration guide for cljs-rest 1.0.0

Configuration

An obvious use case that was poorly handled in older versions is to set-and-forget configuration. As such, configuration is now stored as an atom rather than a dynamic var.

0.1.51.0.0
(binding [rest/*opts* ...] ...)N/A [Dynamic binding]
(set! rest/*opts* ...)(swap! rest/config assoc :request-defaults ...) [Request options]
:response-format ...(rest/configure-format! ...) (:json, :edn and :transit are supported)

Dynamic binding

It turns out binding does not behave as expected with asynchronous ClojureScript. The best approximate replacement is to include :opts keyword argument when constructing a resource type.

Request options

Because the underlying request library was changed to cljs-http from cljs-ajax, request options were changed accordingly.

Request methods

Methods were renamed to match their respective HTTP verbs.

0.1.51.0.0
rest/readrest/get
rest/create!rest/post!
rest/update!rest/put!

Multipart

0.1.51.0.0
(rest/patch! listing (FormData. ...))(rest/patch! listing (rest/multipart-params {:field val}))

Error handling

0.1.51.0.0
:ok?:success
(get-in resource [:data :status]) etc(:status resource)
:error-handler (fn [err] ...):error-chan (chan)

ResourceListing

0.1.51.0.0
(:data listing)(:resources listing)
(first-item listing)(first-resource listing)

Can you improve this documentation?Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close