component 2022-05-01

Serafeim Papastefanos 2022-05-01T10:19:08.867329Z

I tried using the simple thing, i.e something like this

(comment
  (def system (dev-system (cljcrd.conf/conf (cljcrd.conf/env))))
  (alter-var-root #'system component/start)
  (alter-var-root #'system component/stop)
  )
and it works fine ! starting and stopping are idempotent and work fine! ty again

Serafeim Papastefanos 2022-05-01T10:47:31.612929Z

@seancorfield I saw you don't recommend using the tools.namespace ; how do you "reload" a webapp when something changes ? use ring.middleware.reload ?

If you haven't already, see Sean's presentation at London Clojurians https://www.youtube.com/watch?v=gIoadGfm5T8

If a function definition has changed (in a file), just re-eval that function in the REPL. If you do that every time you make any changes, the REPL state will be in sync with the file state.

Similarly, if some data file has changed, re-run any functions that maintain any state that depends on the changed data.

Serafeim Papastefanos 2022-05-01T17:01:21.396589Z

thank you both for explaining

I don't "reload a webapp" -- I just eval the changed code into the REPL.

Serafeim Papastefanos 2022-05-01T17:01:49.041669Z

so you change the code in your editor and re-eval immediately

Serafeim Papastefanos 2022-05-01T17:02:00.473499Z

yes that's a great way of workin

Every time I change a function I hit a hot key that does "eval top block" so the new definition is in the REPL, and I use #'func references instead of func so that passing functions as HOF will pick up the new version automatically (per that http://clojure.org page).

No "reload", no "refresh", no file watchers. Always eval everything into the REPL from your editor as you work. That's how my REPLs stay up and running for weeks.

Serafeim Papastefanos 2022-05-01T17:04:55.043069Z

could you explain the #'func bit? where should i use that instead of func ? whenever a function is passed ?

Read the link I posted.

(it's explained better there than I can)

🙌 1