# fireEvent()
fireEvent
replaces Ti.App.fireEvent
in an asynchronous way. You will not need to provide any callbacks anymore as this will
be handled internally and unique callbacks will be generated. This also eliminates bugs where 2 events fire for the same callback
function.
This helper also accepts a third argument for timeout. When this argument is provided the event gets timed out and cancelled after that amount of milliseconds.
Example:
import { fireEvent } from '@pitcher/core'
// Recommended way
const result = await fireEvent('dbFunction', {
'query': query,
'pType': 'query',
'db': 'pitcher',
})
console.log(result)
// Old promise way
fireEvent('dbFunction', {
'query': query,
'pType': 'query',
'db': 'pitcher',
}).then((result) => {
console.log(result)
...
})
In the section below, you can find Ti.App documentation and the event list you can use with fireEvent()
function in @pitcher/core