Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON format support #8

Merged
merged 10 commits into from
Mar 21, 2014
Merged

JSON format support #8

merged 10 commits into from
Mar 21, 2014

Conversation

michaelklishin
Copy link
Contributor

As discussed over email.

@jarohen
Copy link
Owner

jarohen commented Mar 12, 2014

Thanks Michael :)

I've moved your snippet into chord.http-kit - unless Chord goes down the route of making JSON support optional (which I'm quite open to - discussion in #9) I think it'd be easier for users to just have one NS to require.

I've also mirrored the feature in the CLJS version (I really should get around to migrating Chord to CLJX!), updated a few docstrings and cut a 0.3.1-rc1 release - could you let me know whether this works for your use case? If so, I'll cut a stable version tomorrow.

Thanks again,

James

@michaelklishin
Copy link
Contributor Author

I get

TypeError: 'undefined' is not an object (evaluating 'chord.http_kit.wrap_format')

with the following CLJS code with 0.3.1-rc1:

(ns azondi.events
  (:require [chord.client :refer [ws-ch]]
            [cljs.core.async :refer [<! >! put! close! timeout]]
            [cljs.reader :as edn])
  (:require-macros [cljs.core.async.macros :refer [go]]))

(set! (.-onload js/window)
      (fn []
        (go
          (let [ws (<! (ws-ch "ws://127.0.0.1:8083/events/stream"))]
            ))))

and the line seems to be

cljs.core._add_method.call(null, chord.http_kit.wrap_format, new cljs.core.Keyword(null, "json", "json", 1017176154), function(p__11553, _) {
    var map__11554 = p__11553;
    var map__11554__$1 = cljs.core.seq_QMARK_.call(null, map__11554) ? cljs.core.apply.call(null, cljs.core.hash_map, map__11554) : map__11554;
    var write_ch = cljs.core.get.call(null, map__11554__$1, new cljs.core.Keyword(null, "write-ch", "write-ch", 3462353029));
    var read_ch = cljs.core.get.call(null, map__11554__$1, new cljs.core.Keyword(null, "read-ch", "read-ch", 2094260078));
    return new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null, "read-ch", "read-ch", 2094260078), cljs.core.async.map_LT_.call(null, chord.client.try_read_json, read_ch), new cljs.core.Keyword(null, "write-ch", "write-ch", 3462353029), cljs.core.async.map_GT_.call(null, cljs.core.clj__GT_js, write_ch)], null);
})

@michaelklishin
Copy link
Contributor Author

I believe I've corrected the issue. Can you please push rc2?

@michaelklishin michaelklishin mentioned this pull request Mar 13, 2014
@jarohen
Copy link
Owner

jarohen commented Mar 14, 2014

Thanks, deployed rc2

@jarohen
Copy link
Owner

jarohen commented Mar 14, 2014

I'm currently working on updating the example project to test the JSON support but haven't quite managed to make it work yet. Will probably have time over the weekend to finish this off.

James

@michaelklishin
Copy link
Contributor Author

It seems to be good to go.

@michaelklishin
Copy link
Contributor Author

@james-henderson let me know if you want anything else done to this PR.

@jarohen jarohen merged commit 9f01fea into jarohen:master Mar 21, 2014
@jarohen
Copy link
Owner

jarohen commented Mar 21, 2014

Hi Michael, sorry for the delay, have had a hectic week.

I've added support for :json-kw as well, to keywordize any map keys passed via JSON, and released 0.3.1.

Thanks for your help!

James

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants