You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.2 KiB

import {Event, SerialPayload} from '../types'
import {ObjectSerializer} from './decorators'
import {BaseSerializer} from './BaseSerializer'
import {JSONState} from '../../../util'
export class NamedEventPayload {
public readonly eventName: string,
public readonly event: Event,
) {}
export class NamedEventPayloadSerializer extends BaseSerializer<NamedEventPayload, { eventName: string, event: SerialPayload<Event, JSONState> }> {
protected async decodeSerial(serial: { eventName: string; event: SerialPayload<Event, JSONState> }): Promise<NamedEventPayload> {
return new NamedEventPayload(
await this.getSerialization().decode(serial.event),
protected async encodeActual(actual: NamedEventPayload): Promise<{ eventName: string; event: SerialPayload<Event, JSONState> }> {
return {
eventName: actual.eventName,
event: await this.getSerialization().encode(actual.event),
protected getName(): string {
return '@extollo/lib:NamedEventPayloadSerializer'
matchActual(some: NamedEventPayload): boolean {
return some instanceof NamedEventPayload