mirror of
https://github.com/penpot/penpot.git
synced 2025-05-10 14:06:37 +02:00
🔊 Add some logging to worker modules.
This commit is contained in:
parent
fada526f5d
commit
fcc7351552
2 changed files with 6 additions and 2 deletions
|
@ -25,13 +25,11 @@
|
||||||
|
|
||||||
;; This excludes webworker instantiation on nodejs where
|
;; This excludes webworker instantiation on nodejs where
|
||||||
;; the tests are run.
|
;; the tests are run.
|
||||||
|
|
||||||
(when (not= *target* "nodejs")
|
(when (not= *target* "nodejs")
|
||||||
(defonce worker (uw/init "/js/worker.js")))
|
(defonce worker (uw/init "/js/worker.js")))
|
||||||
|
|
||||||
(defn align-point
|
(defn align-point
|
||||||
[point]
|
[point]
|
||||||
|
|
||||||
(let [message {:cmd :grid-align :point point}]
|
(let [message {:cmd :grid-align :point point}]
|
||||||
(->> (uw/ask! worker message)
|
(->> (uw/ask! worker message)
|
||||||
(rx/map :point))))
|
(rx/map :point))))
|
||||||
|
|
|
@ -6,12 +6,16 @@
|
||||||
|
|
||||||
(ns uxbox.worker
|
(ns uxbox.worker
|
||||||
(:require [beicon.core :as rx]
|
(:require [beicon.core :as rx]
|
||||||
|
[cuerdas.core :as str]
|
||||||
[uxbox.util.transit :as t]
|
[uxbox.util.transit :as t]
|
||||||
|
[uxbox.util.uuid :as uuid]
|
||||||
[uxbox.worker.impl :as impl]
|
[uxbox.worker.impl :as impl]
|
||||||
[uxbox.worker.align]))
|
[uxbox.worker.align]))
|
||||||
|
|
||||||
(enable-console-print!)
|
(enable-console-print!)
|
||||||
|
|
||||||
|
(defonce id (uuid/random))
|
||||||
|
|
||||||
(defn- on-message
|
(defn- on-message
|
||||||
[event]
|
[event]
|
||||||
(let [message (t/decode (.-data event))]
|
(let [message (t/decode (.-data event))]
|
||||||
|
@ -19,3 +23,5 @@
|
||||||
|
|
||||||
(defonce _
|
(defonce _
|
||||||
(.addEventListener js/self "message" on-message))
|
(.addEventListener js/self "message" on-message))
|
||||||
|
|
||||||
|
(println (str/format "Worker with id '%s' is initialized." id))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue