Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(): refactor request-scoped event payload
refactor request-scoped event payloads to increase the readability and reduce the burden to add other request payload types in the future
- Loading branch information
1 parent
929a3ea
commit b434bd6
Showing
3 changed files
with
35 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* Class used to test injected payloads on the RequestScoped listener. | ||
* Each value stored in the instance represents a different type of payload. | ||
*/ | ||
export class RequestScopedEventPayload { | ||
public objectValue: Record<string, any>; | ||
public arrayValue: any[]; | ||
public stringValue: string; | ||
|
||
constructor() { | ||
this.objectValue = {}; | ||
this.arrayValue = []; | ||
this.stringValue = ''; | ||
} | ||
|
||
public setPayload(value: any) { | ||
if (Array.isArray(value)) { | ||
this.arrayValue = value; | ||
} else if (typeof value === 'string') { | ||
this.stringValue = value; | ||
} else { | ||
this.objectValue = value; | ||
} | ||
} | ||
} |