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.
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
If you're feeling friction from the reitit/compojure discrepancies, I'll point out that reitit works on the server too.
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
Is there no protocol? fn to check if a given value is a protocol?
what would be the use case?
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.
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?
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.
Protocols donโt really share any common root thing - youโre making a new abstraction