Skip to content

Commit

Permalink
send-update-url for manually sending update
Browse files Browse the repository at this point in the history
  • Loading branch information
knobo committed Jul 11, 2018
1 parent 782e5d2 commit 4088803
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 5 additions & 2 deletions live-reload.lisp
Expand Up @@ -20,6 +20,10 @@
(pushnew url (gethash file *files*) :test 'equal)
(inotify:add-watch inot file mask)))

(defun send-update-url (url)
(dolist (client (alexandria:hash-table-keys *live-reload-clients*))
(wsd:send client (format nil "{\"command\":\"reload\",\"path\":\"~a\",\"liveCSS\":\"true\"}" url))))

(defun event-listener (inot)
(declare (optimize (debug 3)))
(loop for events = (inotify:read-events inot :time-out 0.2)
Expand All @@ -28,8 +32,7 @@
(let* ((pathname (inotify:event-full-name event))
(urls (gethash pathname *files*)))
(dolist (url urls)
(dolist (client (alexandria:hash-table-keys *live-reload-clients*))
(wsd:send client (format nil "{\"command\":\"reload\",\"path\":\"~a\",\"liveCSS\":\"true\"}" url))))
(send-update-url url))
(log:info "Notify update:" urls)))))

(defmacro mlcar ((el list) &body body)
Expand Down
3 changes: 2 additions & 1 deletion package.lisp
Expand Up @@ -7,4 +7,5 @@
#:add
#:run-thread
#:stop
#:*live-reload-clients*))
#:*live-reload-clients*
#:send-update-url))

0 comments on commit 4088803

Please sign in to comment.