Skip to content

Instantly share code, notes, and snippets.

@chpill
chpill / on-the-client.cljs
Last active May 21, 2017 14:17
An example of some server code to encode clojure data as transit, and some client code to decode the transit into clojurescript datastructures.
(ns on-the-client
(:require [cognitect.transit :as transit]))
;; Let's imagine the server has written the transit payload into this tag:
;; <script type="application/json" id="my-app-data">...</script>
;; This will output the original clojure data
(->> (js/document.getElementById "my-app-data")
.-innerHTML
(transit/read (transit/reader :json)))