component

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 ?

dorab 2022-05-01T16:50:58.878689Z

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

dorab 2022-05-01T16:51:27.355049Z

The slides are at https://corfield.org/articles/REPL-Driven-Development.pdf

dorab 2022-05-01T16:53:16.520119Z

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.

dorab 2022-05-01T16:54:59.627619Z

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

seancorfield 2022-05-01T17:01:23.908099Z

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

seancorfield 2022-05-01T17:02:50.448769Z

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).

seancorfield 2022-05-01T17:03:38.686619Z

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 ?

seancorfield 2022-05-01T17:05:41.777009Z

Read the link I posted.

seancorfield 2022-05-01T17:05:51.821999Z

(it's explained better there than I can)

🙌 1