Fork me on GitHub
#hyperfiddle
<
2023-03-18
>
Dustin Getz14:03:08

We're doing a hack week next week, any ideas as to what we should build? I list some ideas here: https://twitter.com/dustingetz/status/1637081011761684480

Lidor Cohen17:03:20

Mega like 👆

👍 2
Dustin Getz20:03:39

@UEJ28A9PH help me imagine what this spreadsheet would be used for, is this just a simple google sheets thing where you can add and remove rows and assign values? What is the business use case that you have in mind

Dag23:03:09

- Electric DataScript - Electric DAG viewer Really interested in these two!!

8
Andreas Edvardsson07:03:56

Bacisally a google sheets clone with som simple formulas and stuff. I didnt have a business case in mind, just thought it would be cool. Especially if it was still performant with somewhat large data sets :) However, the other ideas are indeed more useful 👍

Lidor Cohen08:03:49

How about instead of using some kind of mock excel language (=IF(...)) we'd "sink" back to clojure? I.e formulas would be clojure exp which can reference other cells in the spreadsheet? Besides the obvious power proof for electric, a spreadsheet that can tap into clojure, IMHO, would be priceless...

👍 2
Adrian Smith09:03:30

I'd like to see business applications with forms validations, form sessions, multipart forms, dialogs, file upload, consideration for conflicting updates, form history - everything you'd want to do a generic web form, defined declaratively for easy implementation

👍 4
teodorlu17:03:20

I'd like to see an extensible, lightweight database UI. Connect to datasource (next.jdbc?), browse around. Could be interesting as a sidecar when developing. Seeing the database state live, possibly extending the viewers. Easy batch editing.

beders18:03:16

Hello there, getting my feet wet with electric and I’m already trying something impossible 😉 I’d like to use the highlight.js library and looking for a way to mutate a DOM element after it has been mounted. The MDN answer is: use MutationObservers, but for those I also need a reference to the DOM element. Any idea on how to do this?

2
beders18:03:11

(I’ve spotted the on! and on fns/macros but there’s no suitable DOM event anymore to attach to)

xificurC19:03:10

Can you elaborate a bit on the use case? Their web page shows simple examples that should work in electric as is

Dustin Getz20:03:31

dom/node is in dynamic scope, it is the node at current point

beders21:03:21

thank you so much for the pointers!

🙂 2
beders03:03:03

getting closer and what I really need is an effect that runs when a node updates (so I can ask highlight.js to highlight the current node again) So stuff like this works:

(dom/code (dom/props {:class "language-clojure"})
                   (dom/text "{:a :b}")
                   (highlight/highlightElement dom/node))
but this won’t, since it doesn’t re-run highlightElement.
(dom/code (dom/props {:class "language-clojure"})
                   (dom/text (e/server (pr-str project)))
                   (highlight/highlightElement dom/node))
Which should be obvious to me if I would know electric a bit better 😉

👀 2
beders03:03:00

I haven’t found an example yet that shows how to integrate with one of those good old-fashioned JS libraries that want a dom element to mess with (and don’t observe any DOM changes themselves)

beders04:03:32

switched to a WebComponent and that works. No need to investigate further.

Dustin Getz14:03:58

I dont understand the webcomponent fix, can i see the code?

Dustin Getz14:03:36

> what I really need is an effect that runs when a node updates (so I can ask highlight.js to highlight the current node again) Here is a solution, it requires you to think in terms of the DAG / reactivity graph

(defn highlight! [node _] 
  (highlight/highlightElement dom/node))

(dom/code (dom/props {:class "language-clojure"})
  (dom/text (e/server (pr-str project)))
  (highlight! dom/node project)) ; establish reactive dependency on project

beders21:03:31

Oh. I see. I have to reference project

👍 2
beders21:03:57

I’ve since switched to a web component that takes the data from project directly and that makes it reactive

Dustin Getz21:03:17

I'd like to see it [webcomponent] if it is easy to copy/paste

beders04:03:08

I’m using this one: https://github.com/alenaksu/json-viewer Here’s my example component. Surprisingly it can deal with CLJS objects.

(e/defn JSONView []
  (e/server
    (binding [project (e/watch d/project)]
      (e/client
       (dom/div
        (dom/element "json-viewer"
                     (dom/props {:data (e/server project)}))
        )))))
(calling :data (cljs->js (e/server project)) fails with an error message for reasons unknown)

beders04:03:45

if project changes, it re-renders. Very fast.

beders04:03:41

json-viewer doesn’t quite fit the bill as keys are unsorted, so I might build my own viewer for tree-like data-structures anyways. Sigh. Too much effort to fork json-viewer, change one line, and get it into the project 😉

nakkaya21:03:05

Hi, I use the following for history (slightly modified from electric examples.) [1] This used to work no issues since switching to master I started getting the following error, back/forward navigation still works but I lost the ability to reload the app from a specific view. i.e /app#/some-page [1] https://gist.github.com/nakkaya/fb5acbebf8ff7a4f468fa92b6a0b7342

👀 2
Dustin Getz23:03:47

i have no idea, will look into it tomorrow, if you can link me to the right place in your repo that would help

xificurC09:03:52

I get page not found on your links

Dustin Getz21:03:25

from @sr (who did Electric Painter) - one day

Dustin Getz00:03:37

The demo (and other game demos) has input latency, I spoke with Dag about it. We're going to fix it. The issue is that Electric's operators are designed for database apps, Electric has optimistic form controls but games don't match the form pattern

nivekuil02:03:56

more info on how you plan on doing that? sounds like a major undertaking

nivekuil02:03:12

form inputs are easy because the user is the source of truth

Dustin Getz13:03:21

we don't intend to abstract over conflict resolution, which is the hard part right? userland can arrange a transaction or CRDT strategy

Dustin Getz13:03:01

abstractly, a form is a sequence of keyboard events, and a mouse gesture is a sequence of mouse events, and a game input is a sequence of keyboard events, I think the naive interactions can be fast like our form elements are

nivekuil13:03:10

Is "clicked on a thing" a mouse event? server and client may disagree on whether that happened

Dustin Getz13:03:52

that's a conflict, we don't intend to abstract over that

Dustin Getz13:03:11

+ we need a user story, "clicked on a thing" is a fact, and the client has authority over that fact

Dustin Getz14:03:31

We also just discovered two additional issues 1. Railway has 200ms ping across the atlantic ocean whereas http://fly.io has 30ms for the same 2. in the painter app, DOM performance slows down linearly with number of strokes, this is a userland issue that i will help fix and of course (3) the optimistic state update issue remains (in games not forms) even with low ping, we take that seriously

Dustin Getz16:03:45

@sr we fixed the glitchy input, it was a mistake in the userland code in the RPG app, sent you a PR

😎 2