2b96cbcad7
* expose old row through the emitter * accidentally added oldRow to step * fix row fetch in external datasources * add test for new / old row comparison * add testing for old row update event * allow function overloading in test files * update tests per comments * handle event race condition * update test data modal to account for old row output * switch icon positioning
35 lines
1,017 B
TypeScript
35 lines
1,017 B
TypeScript
import { EventEmitter } from "events"
|
|
import { rowEmission, tableEmission } from "./utils"
|
|
import { Table, Row } from "@budibase/types"
|
|
|
|
/**
|
|
* keeping event emitter in one central location as it might be used for things other than
|
|
* automations (what it was for originally) - having a central emitter will be useful in the
|
|
* future.
|
|
*/
|
|
|
|
/**
|
|
* Extending the standard emitter to some syntactic sugar and standardisation to the emitted event.
|
|
* This is specifically quite important for template strings used in automations.
|
|
*/
|
|
class BudibaseEmitter extends EventEmitter {
|
|
emitRow(
|
|
eventName: string,
|
|
appId: string,
|
|
row: Row,
|
|
table?: Table,
|
|
oldRow?: Row
|
|
) {
|
|
rowEmission({ emitter: this, eventName, appId, row, table, oldRow })
|
|
}
|
|
|
|
emitTable(eventName: string, appId: string, table?: Table) {
|
|
tableEmission({ emitter: this, eventName, appId, table })
|
|
}
|
|
|
|
emitPort(portNumber?: number | string) {
|
|
this.emit("internal:port", portNumber)
|
|
}
|
|
}
|
|
|
|
export default BudibaseEmitter
|