Fork me on GitHub
#clojurescript
<
2024-02-24
>
김태희 (Taehee Kim)06:02:21

I'm attempting to create declarative @tanstack/query-core adapter for reagent state. (Like atom, reaction, etc...) Can you recommend any other similar attempts or posting?

김태희 (Taehee Kim)06:02:53

here is my prototype example.

(def health-reaction 
   (reaction-query-req (fn [] {:query-key ["health"] 
                               :endpoint  "/health"}))) 
  
 
 (def derived-key-health-reaction 
   (reaction-query-req (fn [] {:query-key ["health" @key-atom] 
                               :endpoint  "/health" 
                               :enabled   (= (:status @health-reaction) :success)}))) 
  
 (def length-reaction 
   (ratom/make-reaction #(count (@health-reaction :data)))) 
  
 (defn app 
   [] 
   (let [{:keys [data status loading?] :as result} @health-reaction] 
     (prn result) 
     [:div.v-stack {} 
      [:li (str ":data " data)] 
      [:li (str ":status " status)] 
      [:li (str ":loading? " loading?)] 
      [:li (str "derived track " @length-reaction)] 
      [:li (str "derived key status " (@derived-key-health-reaction :status))] 
      [:br]])) 
 

김태희 (Taehee Kim)06:02:23

It is just a subscription to server resource. Unsubscribe :on-dispose.

p-himik08:02:17

I'd move this to #C0620C0C8.

1
aaelony19:02:44

Does anyone know how to use the following library from clojure or clojurescript? https://github.com/alvarcarto/url-to-pdf-api?tab=readme-ov-file#development I have CSS/HTML that I need to render into PDF files (without going the LaTEX route via pandoc)..

Adam Mertzenich19:02:18

Are you required to use that project in particular or are you open to alternative solutions?

aaelony20:02:50

Only requirement is to be able to render nice looking CSS/HTML to pdf programatically from a docker container

Adam Mertzenich20:02:16

In that case, Etaoin might serve you well. It has a print-page function that lets you use a headless browser to render the page to a PDF. https://cljdoc.org/d/etaoin/etaoin/1.0.40/doc/readme https://cljdoc.org/d/etaoin/etaoin/1.0.40/doc/user-guide#_print_page_to_pdf

aaelony20:02:18

sounds great, thank-you I will take a look. I also found a clj-pdf library to investigate

valerauko11:02:59

unless you want to interface with some C library directly you'll have to use a headless browser for PDF rendering sadly. i ended up going with calling into puppeteer (which should be possible from a cljs server too)

aaelony17:02:31

Headless in a docker container is what I'm aiming for, indeed. Considering phantomjs as well

grav07:02:15

Browserless is an easy solution: https://www.browserless.io/ It has a simple https://www.browserless.io/docs/pdf`/pdf` that lets you render a webpage to a PDF file.

grav07:02:09

It's more or less a wrapper for Puppeteer, but it has a lot of niceties. Docker quick start: https://www.browserless.io/docs/docker-quickstart

aaelony20:02:50

sounds nice, but my guess is this wouldn't be viable if the report contents contain sensitive info

valerauko23:02:36

You'd probably need to negotiate an Enterprise License or something like that with them and include a confidentiality clause in the contract

grav05:02:37

> my guess is this this wouldn't be viable if the report contents contain sensitive info Because of technical reasons, or related to license?

aaelony02:02:59

That's great. Yeah, not my decision to make. First step is getting acquainted with the lay of the land. Thanks for that to all who replied

🤞 1