rabbibotton / clog

CLOG - The Common Lisp Omnificent GUI
Other
1.48k stars 101 forks source link

Feature request : Hot Reload / Live Reload #354

Closed 0fflineuser closed 1 month ago

0fflineuser commented 1 month ago

Hi,

I think they would be great for when developping, as it would eliminate the need to manually refresh the web page and allowing us to instantly see changes in the browser.

Examples :

rabbibotton commented 1 month ago

Not sure why you would not do it in your code with (reload (location body)) or at a REPL (just set a global to current window while testing)?

On Sun, May 26, 2024 at 10:27 AM 0fflineuser @.***> wrote:

Hi,

I think they would be great for when developping, as it would eliminate the need to manually refresh the web page and allowing us to instantly see changes in the browser.

Examples :

— Reply to this email directly, view it on GitHub https://github.com/rabbibotton/clog/issues/354, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACYUEFLE5DI4WLRFN3QFI5DZEHWMNAVCNFSM6AAAAABIJ3DV7CVHI2DSMVQWIX3LMV43ASLTON2WKOZSGMYTONZTHE2TGMI . You are receiving this because you are subscribed to this thread.Message ID: @.***>

rabbibotton commented 1 month ago

If you mean individual elements. same exact thing - just do it. CLOG is always live. Maybe give me example as you may not have made the leap to a CLOG brain yet :)

CLOG is the original hot load :)

(setf t (create-div body :content "hello") (setf (text-value t) "Hello World!")

On Sun, May 26, 2024 at 10:37 AM David Botton @.***> wrote:

Not sure why you would not do it in your code with (reload (location body)) or at a REPL (just set a global to current window while testing)?

On Sun, May 26, 2024 at 10:27 AM 0fflineuser @.***> wrote:

Hi,

I think they would be great for when developping, as it would eliminate the need to manually refresh the web page and allowing us to instantly see changes in the browser.

Examples :

— Reply to this email directly, view it on GitHub https://github.com/rabbibotton/clog/issues/354, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACYUEFLE5DI4WLRFN3QFI5DZEHWMNAVCNFSM6AAAAABIJ3DV7CVHI2DSMVQWIX3LMV43ASLTON2WKOZSGMYTONZTHE2TGMI . You are receiving this because you are subscribed to this thread.Message ID: @.***>

0fflineuser commented 1 month ago

Thanks a lot ! I am new to common lisp and clog. I see that reload is in the manual and used in the tutorial 14, sry I missed it.

So for the live reload I did the following :

(defun dev-live-reload ()
  (progn
   (if (not (boundp '*CURRENT-WINDOW*))
       (defparameter *CURRENT-WINDOW* nil))
   (if (and *CURRENT-WINDOW* (equal (type-of *CURRENT-WINDOW*) 'clog-location))
       (reload *CURRENT-WINDOW*))))

(defun on-index (body)
  (setf *CURRENT-WINDOW* (location body))
  ;; .... 
)

(defun start-app ()
  (initialize 'on-index)
  (open-browser))

;; reload the page
(dev-live-reload)

Now I just do my changes, reload the file and the browser also reload itself !

rabbibotton commented 1 month ago

In most cases you probably don't need to ever reload as you are writing an App not a web page :) You will see :) That is part of the CL power you are having a conversation with it, not writing a program.

On Sun, May 26, 2024 at 11:22 AM 0fflineuser @.***> wrote:

Thanks a lot ! I am new to common lisp and clog. I see that reload is in the manual and used in the tutorial 14, sry I missed it.

So for the live reload I did the following :

(defun dev-live-reload () (progn (if (not (boundp 'CURRENT-WINDOW)) (defparameter CURRENT-WINDOW nil)) (if (and CURRENT-WINDOW (equal (type-of CURRENT-WINDOW) 'clog-location)) (reload CURRENT-WINDOW))))

(defun on-index (body) (setf CURRENT-WINDOW (location body)) ;; .... )

(defun start-app () (initialize 'on-index) (open-browser)) ;; reload the page (dev-live-reload)

Now I just do my changes, reload the file and the browser also reload itself !

— Reply to this email directly, view it on GitHub https://github.com/rabbibotton/clog/issues/354#issuecomment-2132257725, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACYUEFOW7AZ3OKWOXP6WUDTZEH42XAVCNFSM6AAAAABIJ3DV7CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMZSGI2TONZSGU . You are receiving this because you commented.Message ID: @.***>

aykaramba commented 1 month ago

Also, if you use Emacs or lem, you can just bind a key binding to call something like:

  (defun reload (obj)
    (url-replace (location body) "/"))

Here is my Lem binding: https://github.com/aykaramba/edgar/blob/main/commands.lisp

I load that up in my EDGAR project, it is Lem specific. I need to write one for Emacs as well.

When I am coding in C-c all the time and when I want to see my changes updated in the browser I just C-v whenever I want.