Fork me on GitHub
#clojurescript
<
2022-07-13
>
Muhammad Hamza Chippa08:07:56

Did anybody used recoil in the clojurescript project, and if yes what is your experience?

Tala Tarazi10:07:41

Hi all, I'm trying to implement this code in Clojurescript, can anyone help me convert it. Thanks!

const { root } = await room.getStorage();

  let todos = root.get("todos");

p-himik10:07:10

(.. room
    (getStorage)
    (then (fn [^js storage]
            (let [todos (.. storage -root (get "todos"))]
              ...))))

Tala Tarazi10:07:21

This works, but I want the todos value to be outside the let, so I can use it in other functions. Is there a way to save it in a global value?

Hermann10:07:10

I assume you're creating a Todo-App for the frontend and use something like reagent, re-frame, rum, om... for the rendering?

Tala Tarazi10:07:35

No Actually, I'm using a service and this is their example and I want to do something similar

p-himik10:07:55

> I want the todos value to be outside the let Impossible, both in CLJS and in JS. In JS, it seems like it's possible, because the outer function is an async one - you still have to await it somewhere or use .then on the returned promise. CLJS doesn't have await support, so you have to use .then. You can, however, pass the resulting promise anywhere you like - then the relevant functions would call .then on it themselves. Alternatively, you can rewrite the above code to use clojure.core.async - it can end up looking very similar to the JS code with async/`await`.

👍 3
M J12:07:43

Anyone know how can I copy a value to clipboard in clojurescript?

p-himik12:07:22

Exactly the same way you'd do it using JS.

p-himik12:07:31

But, of course, with some JS interop on top.

reefersleep12:07:34

[:button {:on-click (fn [e]
                         (.writeText js/navigator.clipboard "wow"))}
    "Click me!"]
works for me

🙌 1
M J12:07:42

YES thanks alot!!

🍻 1
hoynk23:07:19

Not clojurescript related, but does anyone recommend a rich text editor to embed as a web-component in a page? If it looks/works like the one on slack, it is good enough.

Aleed04:07:29

if you’re using React maybe check out Lexical not sure if it’s as batteries included as what you’re looking for though

p-himik04:07:39

I've used TinyMCE before, seemed alright. Has a separate wrapper for React.

biscuitpants06:07:11

Quill worked quite well for us, but once you want to do complex things (like custom nodes) it becomes a bit cumbersome. we're currently using Tiptap (built upon ProseMirror) which is fantastic. definitely not batteries included but it makes adding custom functionality very simple

seepel07:07:48

I was just shopping for one myself and found this article that I found useful: https://areknawo.com/top-js-rich-text-editor-frameworks-for-2021/ I decided to go with TipTap, though I haven't gotten very far into the project yet.

biscuitpants07:07:52

if you want any help or experience reports with TipTap feel free to let me know @U03NXD9TGBD 🙂

seepel07:07:53

Thanks @U0HJ7CX6H! any land mines I should avoid? I'm probably going to build something close to a markdown editor that supports hash-tags and at-references

biscuitpants07:07:56

i'll pm you something now 🙂

hoynk14:07:51

Thanks for the answers, looking into them.