Skip to content

Instantly share code, notes, and snippets.

@mariobittencourt
Created July 15, 2020 23:59
Show Gist options
  • Save mariobittencourt/6dcb63073b7e4c81788f99693adb8984 to your computer and use it in GitHub Desktop.
Save mariobittencourt/6dcb63073b7e4c81788f99693adb8984 to your computer and use it in GitHub Desktop.
Order updated with the versioning conversion
class Order {
protected whenOrderCreated(event: OrderCreated): void {
this._items = event.items;
this._status = OrderStatus.OPEN;
this._amount = event.amount;
this._destination = event.destination;
this._customerId = event.customerId;
// New code - detect if we have the property first
if (event.hasOwnProperty('deliveryMethod') {
this._deliveryMethod = event.deliveryMethod;
} else {
// Assume one default from business
this._deliveryMethod = 'Standard';
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment