Created
June 12, 2012 02:36
-
-
Save ohpauleez/2914039 to your computer and use it in GitHub Desktop.
Shoreleave's Web Workers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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