Fork me on GitHub
#clojurescript
<
2021-09-08
>
leif02:09:27

I'm trying to get drag and drop working with reagent, and the closest thing I've found for documentation is: https://stackoverflow.com/questions/22948284/in-reagent-of-clojurescript-how-do-i-add-event-listeners-for-drag-and-drop I gave it a quick try with no luck, so before I look further into it, I would like to know if these attributes are even accurate (given its a random SO post that sources a broken link.)

leif02:09:29

Stuff like on-mouse-down seems to work, but seems to be a much lower-level API.

leif02:09:28

Okay, so its just the on-mouse* api then, rats, thanks anyway. ๐Ÿ™‚

leif03:09:39

Oh, woops, I actually just had it attachedto the wrong DOM element. It actually does look like on-drag-* and on-drop-* work. (At least they seem to be in chromium.)

steveb8n05:09:03

Q: why are some teams moving from devcards/cljs to storybook/typescript? Iโ€™m trying to understand the pros/cons

steveb8n05:09:36

if this was already discussed somewhere, Iโ€™d appreciate the link

David Vujic06:09:49

Hereโ€™s where we chatted about Storybook in the #news-and-articles channel. In a thread I started to promote my blog post about how to implement Storybook in a ClojureScript project ๐Ÿ˜„ https://clojurians.slack.com/archives/C8NUSGWG6/p1630427159059800

David Vujic06:09:59

Not sure if it is a pro or con, but my guess would be that moving to Storybook could be about using tools well known in the JavaScript community.

steveb8n06:09:48

@U018VMC8T0W Thanks! exactly what I was looking for

๐Ÿ‘ 2
steveb8n06:09:17

seems like a good option if I want to outsource the build of the view components without needing to find CLJS devs for the task

robert-stuttaford10:09:13

has anyone got code they can share for dealing with preventing data loss when using the browser's back button? from what i can tell, the strategy needs to be 'save things to local state and restore them if the user used back-then-forwards'

p-himik10:09:51

By "using the back button" you mean navigating to a different website, or to the previous page within the same SPA? What about hitting Refresh or closing and reopening the tab?

robert-stuttaford10:09:30

we have code for onbeforeunload (which covers closing / refreshing), but it doesn't work for the back button/swipe gesture/keyboard shortcut

p-himik11:09:59

If it's not SPA that uses HTML5 history or fragments, then onbeforeunload will be triggered. And if it is that SPA, you should be able to preserve the state upon each navigation. But overall the strategy you describe is correct.

robert-stuttaford11:09:15

sweet, thank you. it's an SPA ๐Ÿ˜„

๐Ÿ‘ 2
yiorgos10:09:42

Hi all, Iโ€™ve got the following function in an .cljc namespace

(defn list-files
  [path]
  (->> path
       io/file
       file-seq
       (filter #(.isFile %))))
and I am trying to use it in a clojurescript namespace it seems like it is not working though, I am getting an error
The required namespace "" is not available. Maybe this library only supports CLJ?

robert-stuttaford10:09:57

cljc means compilable by both compilers. it doesn't also mean 'everything available in each runtime is magically suddenly available in both runtimes'.

robert-stuttaford11:09:28

the runtime still needs to be able to actually run your code, regardless of whether the compiler was able to process it ๐Ÿ™‚

yiorgos11:09:55

Good to know, thank you very much!

yiorgos10:09:07

Is there a way to list all files in a directory with Clojurescript?

yiorgos10:09:01

It is a re-frame app and not a node

p-himik10:09:42

You cannot list files in a local file system from your browser. Otherwise, it would be a security hole.

๐Ÿ‘ 4
Nik11:09:18

Hey, I been searching for a starter template for clojurescript+electron. I noticed most of them are very old (~4-7 years) and stuck at electron v8. It feels like a pattern, does anyone know why there is no, a more updated project anywhere (tried ddg, google, github, gitlab). I'm doing electron for first time.

Jon Boone14:09:11

Hi! This is the kind of thing I was worried about with my current Analogues code. Perhaps it would be helpful to approach it slightly differently: what if Analogues was brought up to date with the latest electron + node version? Once it works, the backend could be replaced with Clojure โ€” pushing off the task of getting clojurescript working with Electron could be deferred a while?

Nik14:09:53

That's one way to do it. I'm starting from the electron side. I'm trying out basic setup then I'll add things one by one from Logseq's setup since they have everything (and more)

Nik14:09:53

Since there's no rush, I want to use this opportunity to get more realistic practice with Clojure.

Nik12:09:21

@U8LB00QMD That was one of the first ones I saw. npm is giving all sorts of deprecation warnings along with 2 high severity vulnerabilities. It is also based on electron 8 and I get (electron:50826): Pango-ERROR **: 17:55:51.625: Harfbuzz version too old (1.2.7)

thheller15:09:49

FWIW shadow-cljs hasn't changed config wise. so bumping shadow-cljs and electron to the latest version might just work?

2
Nik15:09:21

wow @U05224H0W , I've been so used to things breaking when I upgrade stuff that I didn't even try it out. Thank you!

thheller15:09:17

no idea about the electron parts but CLJS should be fine

Nik16:09:50

Seems to be working all right so far.

Nik16:09:50

Also, could be the reason why no one bothered updating anything, anywhere :rolling_on_the_floor_laughing:

leif16:09:42

Are there any good tools for memory profiling in clojurescript? (Or even just analyzing a single memory dump.)

leif16:09:04

The chrome dev tools seem to give information in terms of the underlying js objects.

leif16:09:22

(Which sometimes seem tricky to map back to source.)