{"id":15652936,"url":"https://github.com/oliyh/oxbow","last_synced_at":"2026-03-15T10:01:51.285Z","repository":{"id":46245549,"uuid":"301750098","full_name":"oliyh/oxbow","owner":"oliyh","description":"A Server Sent Events (SSE) client for Clojurescript based on js/fetch","archived":false,"fork":false,"pushed_at":"2023-10-27T11:01:50.000Z","size":46,"stargazers_count":32,"open_issues_count":1,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-29T07:41:31.474Z","etag":null,"topics":["clojurescript","fetch","re-frame","server-sent-events","sse","streams"],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oliyh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["oliyh"]}},"created_at":"2020-10-06T14:14:07.000Z","updated_at":"2025-01-20T20:14:32.000Z","dependencies_parsed_at":"2022-09-25T05:10:58.863Z","dependency_job_id":"6205b278-4e8a-43f4-bf02-b2f7d342900b","html_url":"https://github.com/oliyh/oxbow","commit_stats":{"total_commits":24,"total_committers":1,"mean_commits":24.0,"dds":0.0,"last_synced_commit":"d02180fa6bf8c3421bb96850673925ea156f67d6"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oliyh%2Foxbow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oliyh%2Foxbow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oliyh%2Foxbow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oliyh%2Foxbow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oliyh","download_url":"https://codeload.github.com/oliyh/oxbow/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249690358,"owners_count":21311308,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clojurescript","fetch","re-frame","server-sent-events","sse","streams"],"created_at":"2024-10-03T12:44:18.319Z","updated_at":"2026-03-15T10:01:51.195Z","avatar_url":"https://github.com/oliyh.png","language":"Clojure","funding_links":["https://github.com/sponsors/oliyh"],"categories":[],"sub_categories":[],"readme":"# oxbow\n\nA Server Sent Events (SSE) client for Clojurescript based on js/fetch\n\n[![Clojars Project](https://img.shields.io/clojars/v/oliyh/oxbow.svg)](https://clojars.org/oliyh/oxbow)\n\nThis library uses js/fetch to expose the full functionality of HTTP and processes the SSE data for you.\n\nIt's ready for use as a standalone functional Clojurescript library and also has re-frame bindings for integration\ninto a re-frame application.\n\n## Rationale\n\njs/EventSource is generally moribund and does not support sending headers.\nDiscussions generally reference js/fetch as a modern alternative but it does not natively process streams.\n\n⚠️Chrome Devtools will _not_ show events under the EventSource tab for requests made by js/fetch. See: [Issue 1025893](https://bugs.chromium.org/p/chromium/issues/detail?id=1025893)\n\n## Usage\n\n### Clojurescript\nYou can start a new connection using `sse-client`, which returns a map containing a no-arg abort function under the `:abort` key.\n\n```clj\n(require '[oxbow.core :as o])\n\n(let [{:keys [abort]} (o/sse-client {:uri \"/events\"\n                                     :on-event #(js/console.log \"Got an event!\" %)})]\n\n  ;; events are passed to the callback\n  ;; call abort to close the client\n\n  (abort))\n```\n\n### re-frame\n\nThe re-frame bindings behave the same way, with the addition of `:id` which gives you a handle to abort with.\n\n```clj\n(require '[oxbow.re-frame :as o])\n(require '[re-frame.core :as rf])\n\n(rf/reg-event-db\n  ::on-event\n  (fn [db [_ {:keys [data] :as event}]]\n    (update db :events conj data)))\n\n\n(rf/dispatch [::o/sse-client {:id ::my-events\n                              :uri \"/events\"\n                              :on-event [::on-event]}])\n\n;; events are passed to the callback\n;; call abort to close the client\n\n(rf/dispatch [::o/abort ::my-events])\n```\n\n## Options\n\n```clj\n{:fetch-options     {:headers {\"Authorization\" \"xyz\"}}        ;; options passed to js/fetch, see https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch\n :on-open           #(js/console.log \"Stream connected\" %)    ;; invoked when the stream opens\n :on-close          #(js/console.log \"Stream ended\")          ;; invoked when the stream ends\n :on-event          #(js/console.log \"Message received: \" %)  ;; invoked for every event\n :on-error          #(js/console.warn \"Error: \" %)            ;; invoked on error\n :data-parser       identity                                  ;; parses the `data` value of the event\n :auto-reconnect?   true                                      ;; whether it should automatically reconnect upon disconnection\n :reconnect-timeout 2000                                      ;; ms to wait before attempting reconnect\n }\n```\n\n## Development\n\n`cider-jack-in-cljs` and open the test page http://localhost:9500/figwheel-extra-main/auto-testing\n\nYou will need to also run `(oxbow.server-stub/start-server!)` for the integration tests.\n\n## Build\n[![CircleCI](https://circleci.com/gh/oliyh/oxbow.svg?style=svg)](https://circleci.com/gh/oliyh/oxbow)\n\n## License\n\nCopyright © 2020 oliyh\n\nDistributed under the Eclipse Public License either version 1.0 or (at\nyour option) any later version.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foliyh%2Foxbow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foliyh%2Foxbow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foliyh%2Foxbow/lists"}