Skip to content

Commit 5671af8

Browse files
kwingram25jacogr
authored andcommitted
Allow most recent Result.findRecord (#1559)
* combine values * findRecord newest * constructor * Add filterRecords * Update interface
1 parent 6aebeec commit 5671af8

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

packages/api/src/submittable/Result.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ export default class SubmittableResult implements SubmittableResultImpl {
2727
return this.status.isFinalized;
2828
}
2929

30+
/**
31+
* @description Filters EventRecords for the specified method & section (there could be multiple)
32+
*/
33+
public filterRecords (section: string, method: string): EventRecord[] {
34+
return this.events.filter(({ event }): boolean =>
35+
event.section === section && event.method === method
36+
);
37+
}
38+
3039
/**
3140
* @description Finds an EventRecord for the specified method & section
3241
*/

packages/api/src/submittable/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ export interface SubmittableResultImpl {
1515
readonly isError: boolean;
1616
readonly isFinalized: boolean;
1717

18-
findRecord(section: string, method: string): EventRecord | undefined;
18+
filterRecords (section: string, method: string): EventRecord[];
19+
findRecord (section: string, method: string): EventRecord | undefined;
1920
}
2021

2122
export interface SubmittableResultValue {

0 commit comments

Comments
 (0)