beginners

Christian Dean 2025-06-17T15:35:12.252639Z

Can anyone advise on building a uniform way to handle routing and backend response handling? The context is that I'm using reitit on frontend and compojure on backend. I've started adding Stripe endpoints and webhook handlers so users can subscribe, and I'm realising now that how I handle redirecting and db actions after payment is complicated because I don't have a uniform way to handle all back-and-forth between front and back. One example of complexity is: โ€ข When a user performs an action that edits their user database entry, my frontend function calls the endpoint /edit-user, then the backend returns the field and value which was successfully edited for me to swap into the user app state so it's synced โ€ข But when a user subscribes, I can't have the backend return their new subscribed status because it's a webhook handler which makes the db edit asynchronously So now I don't know what the most common way to handle this is. Is it to redirect them to a pending-page which polls for the status? Any examples of simple, elegant systems like this would be much appreciated.

2025-06-17T15:41:50.996589Z

the pending page polling for status changes is common and I think still the most robust approach to this kind of thing, but now a days you have options like SSE or websockets to push updates to a browser

๐Ÿ‘ 1
๐Ÿ™Œ 1
gaverhae 2025-06-17T15:47:05.071649Z

If you're feeling friction from the reitit/compojure discrepancies, I'll point out that reitit works on the server too.

๐Ÿ™Œ 1
Patrix 2025-06-18T00:17:55.945919Z

The pending page is the way (and thereโ€™s a success url field or something in the stripe checkout session creation endpoint, assuming you are using stripe) Then the success page polls the db for success status, which is handled by the webhooks

๐Ÿ™Œ 1
sheluchin 2025-06-17T23:50:00.704629Z

Is there no protocol? fn to check if a given value is a protocol?

2025-06-18T01:03:38.241649Z

what would be the use case?

sheluchin 2025-06-18T01:05:44.980159Z

I wrote a spec using satisfies? and it blew up when I passed it the wrong kind of value. I wanted to better understand what kind of values I was dealing with and wanted to check if something was a protocol.

๐Ÿ‘ 1
Alex Miller (Clojure team) 2025-06-18T01:56:50.273029Z

you could use #(instance? the.Protocol %) to check if some kinds of values satisfy a protocol. but those defined via metadata extension won't pass either that or satisfies?

sheluchin 2025-06-18T01:58:33.543039Z

I found it odd that there are predicates to check for most types that I'm aware of but there isn't a direct one for checking if something is a protocol.

Alex Miller (Clojure team) 2025-06-18T02:52:05.673389Z

Protocols donโ€™t really share any common root thing - youโ€™re making a new abstraction