
TypeScript Design Patterns
By :

What we've done so far is basically useless. But, from now on, we will start to add features and make it capable of fitting in practical needs, including the capability of synchronizing multiple data items with multiple clients, and merging conflicts.
Ideally, the data we need to synchronize will have a lot of items contained. Directly changing the type of data
to an array would work if there were only very limited number of these items.
Now let's change the type of the data
property of DataStore
and DataSyncingInfo
interfaces to string[]
. With the help of TypeScript, you will get errors for unmatched types this change would cause. Fix them by annotating the correct types.
But obviously, this is far from an efficient solution.
If the data store contains a lot of data, the ideal approach would be only updating items that are not up-to-date.
For example, we can create a...