Skip to content

back ~r Uri type with goog.Uri #16

@sgrove

Description

@sgrove

URIs as tagged values aren't very useful generally speaking, so right now I'm doing:

(deftype URIHandler []
    Object
  (tag [this v] "r")
  (rep [this v] (.toString v))
  (stringRep [this v] nil))

(def transit-reader
  (transit/reader :json
                  {:handlers
                   {"r" (fn [uri] (Uri. uri))}}))

(def transit-writer
  (transit/writer :json
                  {:handlers
                   {goog.Uri (URIHandler.)}}))

Would be nice to actually have this built into transit-cljs, though I'm not sure what the implications for running anywhere that goog.closure has a hard time reaching (self-hosting issue?).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions