Electric Clojure – a signals DSL for fullstack web UI

Testing the data-flow logic only without the presentation layer. […] data and ui and pathways can be tested independently, as do the components - which do not need to know about the network logic to work.

I think you fear mixing client and server code breaks testability. I feared this initially as well, but it turns out to be a non-issue. You can use the same techniques for making your code testable as you’re used to. For example, you can separate a server-side action into an electric function and pass it in as an argument. Now you can substitute that behavior. You can even use a function in your test that doesn’t transfer to the server, so you’re not tied to the network logic in any way!

Hyperfiddle has put a lot of effort into testability. Anecdotally I have yet to find a case where mixing client and server code introduces untestable code. We also have a lot of tests in our repo and have an in-house testing library that is great at async tests.

If you could provide a piece of code you find problematic to test I’d be glad to take a look!

Saving the newest version of the data on the client side and only calling remote updates when necessary. Hasura does this for graphql subscriptions through polling.

Electric is database agnostic. If you want to use e.g. Hasura you can do so.

data that is being pulled in by the app might be displayed in 10 different places spread across different components - so the tight coupling in electric may not be ideal in many of the use cases I’m familiar with.

A typical way to solve this is to request the data once and pass the data down to your components. You can do this in electric much the same way.

If you’re interested you should play around with electric a bit to get a feel of it. I think your fears would quickly dissolve. We’re answering user question in the hyperfiddle slack channel and also provide onboarding zoom calls for those who want a jumpstart!

I think that having a schema on both the backend and the frontend is really important in reconstructing data graphs. Very interested in your thoughts on this.

What schema are we talking about? Your data in your DB is probably tied to a schema. You can also use malli/spec/schema to enforce type constraints on both peers. If you meant something else let me know!

1 Like