Skip to content

Conversation

@Wouter01
Copy link
Member

@Wouter01 Wouter01 commented Apr 28, 2023

Description

This PR addresses an issue where changing settings could be laggy.

The @AppSettings property wrapper has a new initializer, which accepts a keypath to a property in the SettingsData struct. With this, a view will only observe that specific part of the settings struct, resulting in less view updates when a setting has changed. This will hopefully fix the performance issues.

Related Issues

#1247

Checklist

  • I read and understood the contributing guide as well as the code of conduct
  • The issues this PR addresses are related to each other
  • My changes generate no new warnings
  • My code builds and runs on my machine
  • My changes are all related to the related issue above
  • I documented my code

Additional Context

Instead of writing this...

@AppSettings var settings

...you now need to get each setting separately.

@AppSettings(\.textEditing.defaultTabWidth) var defaultTabWidth

Or, if you want to observe a whole subpart of settings you can use...

 @AppSettings(\.textEditing) var textEditing

...which can ease the boilerplate a bit. However, the view will be updated on every change in the text editing settings, so it should be done with care.

The old initializer will display a warning...
image

Signed-off-by: Wouter01 <wouterhennen@gmail.com>
@Wouter01 Wouter01 added the bug Something isn't working label Apr 28, 2023
Signed-off-by: Wouter01 <wouterhennen@gmail.com>
Signed-off-by: Wouter01 <wouterhennen@gmail.com>
Signed-off-by: Wouter01 <wouterhennen@gmail.com>
Signed-off-by: Wouter01 <wouterhennen@gmail.com>
Signed-off-by: Wouter01 <wouterhennen@gmail.com>
@Wouter01 Wouter01 marked this pull request as ready for review April 29, 2023 13:48
@austincondiff austincondiff self-requested a review April 29, 2023 23:08
@austincondiff austincondiff enabled auto-merge (squash) April 29, 2023 23:09
@austincondiff austincondiff merged commit 4624ede into main Apr 30, 2023
@austincondiff austincondiff deleted the settings-performance-improvement branch April 30, 2023 00:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants