Memento Pattern in TypeScript

Throughout the lifecycle of an application, an objects state may change. You might want to store a copy of the current state in case of later retrieval. E.g., when writing a document, you may want to auto save the current state every 10 minutes. Or you have a game, and you want to save the current position of your player in the level, with its score and current inventory.

You can use the Memento pattern for saving a copy of state and for later retrieval if necessary.

The Memento pattern, like the Command pattern, is also commonly used for implementing…




A Design Pattern is a description or template that can be repeatedly applied to a commonly recurring problem in software design. A familiarity of Design Patterns is very useful when planning, discussing, managing and documenting your applications from now on and into the future.

Recommended from Medium

Better caching logic by overwriting mongoose functionality

TypeScript 3.8 Finally Fixes Private Fields

How to Apply Nested Transitions in Vue

My 2 cents about the web in 2020

Day 4: Open the Lock

Simple Dynamic Nav bar based on scroll position (React).

My Goals for HNGI8

Handling JavaScript mouseup event outside element

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Sean Bradley

Sean Bradley

Developer of real time, low latency, high availability, asynchronous, multi threaded, remotely managed, fully automated and monitored solutions.

More from Medium

Interpreter Pattern in TypeScript

Maintaining TypeScript Superpowers When Types Are Out of Reach

Extending TypeScript Generics for Additional Type Safety

Nx 14.4 — Inputs, optional npm scope, project graph cache directory and more!