Order observer
An order notifies subscribers when its status changes; subscriptions can be cancelled and an audit log records transitions.
When an order changes status, several parts of the system must react (customer e-mail, warehouse, audit). The order should not know them – it just notifies observers.
Task
Subscribe/subscribeadds an observer and returns a cancellation handle (IDisposablein C#, a function in TypeScript).ChangeStatus/changeStatus:- the same status → nothing happens (no notifications),
- after
DeliveredorCancelleda change is not allowed (InvalidOperationException/Error), - otherwise it changes the status and notifies all observers in subscription order, passing the previous status.
AuditLogstores entries like#7: New -> Paid(TypeScript:#7: new -> paid).
Topics: Observer