Push API setup with Convex

I currently want to implement the Push API with Convex for my PWA. For that I setup all the neccessary service worker stuff for this to work on the frontend. In my cases with serwist and this example After that I want to trigger an HTTP Action if a message was created and call inside this action the web-push library. Is there anything wrong or missing here in my implementation with Convex?
7 Replies
erquhart
erquhart•9mo ago
Is something not working currently? Specific error or failure mode?
Michal Srb
Michal Srb•9mo ago
Doesn't sound like you need an HTTP Action. You should be able to call serwist from a normal action (and you can schedule it via ctx.scheduler.runAfter(0 from a mutation.
FleetAdmiralJakob 🗕 🗗 🗙
Hi, actually I have to use node in order to use web-push because of all the missing packages what are the benefits of using the scheduler here and not calling the api directly?
Michal Srb
Michal Srb•9mo ago
Actions | Convex Developer Hub
Actions can call third party services to do things such as processing a payment
FleetAdmiralJakob 🗕 🗗 🗙
Is the scheduler just the way of calling an action? Is the intent of the scheduler in this example anything different than calling the action? Thought that the scheduler is the way of not blocking the thread of the mutation
Michal Srb
Michal Srb•9mo ago
Think of ctx.scheduler.runAfter(0 kinda like useEffect in React. The "side-effecty" thing has to go into an action. And the mutation cannot wait on the side-effecty thing, so it has to schedule the action. You can schedule it to run ASAP (After(0) or later
FleetAdmiralJakob 🗕 🗗 🗙
ok, so we use the scheduler to not block the mutation right?

Did you find this page helpful?