PricingDocsAcademy
Bluesky ...
Wed, Dec 11, 9:50 PM

How to think about multiple on success events

  • /attachments/1303966468056023112/1303966468421058581/image.png

    Danny

    1 month ago

    When building an API, there are events, such as on success. However, there are also the same events when building different workflows. I'm curious if anyone has thoughts on when to do it one way vs. the other (screenshots attached). They way I've been thinking about it is setting the event on the API itself if I know it's something I'll always want to do in that instance and setting the event in the course of a workflow if it's specific to a certain instance, but not necessarily something I would want to do in all cases where I might call the API. Also, does the event within the API get called before the event in the workflow?

    Hopefully that makes sense!
    image.png
    image.png
  • Andreas Møller

    1 month ago

    Events on the API are executed before the ones specified on the action: https://toddle.dev/docs/call-apis
  • Andreas Møller

    1 month ago

    In most cases I prefer to have the events on the API, but there are times where the events on the Action are useful.

    Imagine that you have a list of items that is using a repeat formula. Each item has a button on that deletes the item.
  • When you click delete you want to first call the delete API with the id of the item.
    CleanShot_2024-11-07_at_08.41.312x.png
  • And then show a toast message saying the item was deleted
    CleanShot_2024-11-07_at_08.42.302x.png
  • Andreas Møller

    1 month ago

    You cannot call the action to show the toast form the Event in the API panel, since you dont have access to the name from the repeat item.
  • Danny

    1 month ago

    Ah, that makes sense. That seems pretty aligned to what I've been doing, but helpful to hear another explanation. Thanks @Andreas Møller !

Stop scrolling. Start building.

toddle is a visual web app builder that rivals custom code — but accessible to your entire team!

Try toddle — it's free!

© Copyright 2024 toddle. All rights reserved.