mergesort / Boutique

✨ A magical persistence library (and so much more) for state-driven iOS and Mac apps ✨
https://build.ms/boutique/docs
MIT License
899 stars 43 forks source link

Add removeDuplicate() to reduce frequency of persisting side effect #15

Closed pofat closed 2 years ago

pofat commented 2 years ago

This fixes issue 3 in #14.

  1. Unnecessary file rewrite. There's no update interface for @Store now, but you can reproduce with self.$items.add([]). You will find all files are written again even if there's no change.

With a simple removeDuplicate, we can avoid redundant writing because Item is already Equatable

mergesort commented 2 years ago

@pofat This looks like a pretty good change and I'd be happy to integrate it! But could I ask you to match the spacing that currently exists? It doesn't match the spacing of the project, and unfortunately makes the diff very hard to read (so I can verify the changes side by side).

All that said thank you very much for the contribution, looking forward to merging it in.

pofat commented 2 years ago

@mergesort Sorry for messing up the spacing. I am used to go with 2 spaces for SwiftUI projects. It's now fixed. This is actually a one-line PR 😁.

mergesort commented 2 years ago

No problem at all. I'll merge this in, and then start taking a look at your other performance suggestions. Thank you so much for the help, I'm excited to see these changes in action!