Skip to content

Instantly share code, notes, and snippets.

@fogus
Forked from ohpauleez/main.cljs
Created May 8, 2013 13:30
Show Gist options
  • Save fogus/5540433 to your computer and use it in GitHub Desktop.
Save fogus/5540433 to your computer and use it in GitHub Desktop.
(ns barker.client.main
(:require [shoreleave.client.worker :as swk]))
; Take any function in your source...
(defn echo-workerfn [data] data)
; Drop it into a worker...
(def nw (swk/worker echo-workerfn))
; The worker implements IWatchable
(add-watch nw :watcher #(js/console.log (last %4)))
; And you can also deref it, but think about it... that's a terrible idea usually
; (js/console.log (apply str @nw))
(nw "HELLO")
(nw "THREADS")
(comment
The console shows:
HELLO barker.js:23161
THREADS barker.js:23161
That line is the add-watch anon func
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment