Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
TypeScript Design Patterns

You're reading from  TypeScript Design Patterns

Product type Book
Published in Aug 2016
Publisher Packt
ISBN-13 9781785280832
Pages 256 pages
Edition 1st Edition
Languages
Author (1):
Vilic Vane Vilic Vane
Profile icon Vilic Vane

Getting things right


So let's get out of the illusion of comparing code one character at a time and try to find an abstraction that can be applied to updating all of these data types. There are two key points of this abstraction that have already been mentioned in the previous section:

  • A change contains the information that can transform the value of an item from one to another

  • Multiple changes could be generated or applied to one data item during a single synchronization

Now, starting from changes, let's think about what happens when an update method of a client is called.

Finding abstraction

Take a closer look to the method update of client:

  • For data of the 'value' type, first we create the change, including a new value, and then update the change list to make the newly created change the only one. After that, we update the value of data item.

  • For data of the 'increment' type, we add a change including the increment in the change list; or if a change that has not be synchronized already exists...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime}