Skip to content

[docs] Clarify asyncness of eventsΒ #486

@betamos

Description

@betamos

The events guide contains examples showing how to emit events to the backend:

// emits the `click` event with the object payload
emit('click', {
  theMessage: 'Tauri is awesome!'
})

Note that emit returns an empty promise, which is discarded here and suggests an incorrect usage of the API. I suggest that the docs should answer at least these questions:

  • Can these promises be safely discarded without introducing leaks or race conditions with other events or commands? If so...
  • In what circumstances should one await the promise?
  • Are events received in the same order as they are sent, independent of whether the promise is awaited?

My use case:
I will use pure events as the primary comms channel for my app, which can mean thousands of events in both directions. I need strict ordering guarantees and to prevent leaks. I don't need confirmation of delivery (if so, I would have used commands/invoke). All else equal, I'd prefer not to use promises - since it'd require me to asyncify parts of my application without any inherent concurrency.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementDoes it add or improve content?

    Type

    No type

    Projects

    Status

    πŸ’ͺ Ready

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions