Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Add async settings loading and Jetpack datastore support #44

Closed

Conversation

pelmenstar1
Copy link
Contributor

@pelmenstar1 pelmenstar1 commented Aug 20, 2022

  • Async setting loading means that the operation can take some time and result in an error. So I added load-states (Loading, Error, and Success).
  • Also settings are loaded in snapshots because it would be strange if a single setting had its own load state. Besides, it's easier to track the state when snapshots are used.

To add:

  • Screens in demo
  • Controls support
  • Loading indicator
  • Error handling

}
}

inline fun<T> dataStoreSnapshotKey(name: String, resolver: DataStoreSnapshotKeySelector.() -> DataStoreSnapshotKeySelector.Result<T>): DataStoreSnapshot.Key<T> {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't decided which version of key creation is better to use (one with dataStore*type*settingsSnapshotKey or dataStoreSnapshotKey builder). @alorma What do you think?

@alorma
Copy link
Owner

alorma commented Aug 20, 2022

Hi @pelmenstar1

Beside I love the Idea of the async preference, I'm not sure on merging it also with the data store implementation.

So, I've decided to check it and got an approach to use datastore in a synchronous way, I've made the work here:

#45

Could you check it and give me your thought?

That's just a first implementation, later on it could came up with your async solution. But I think it's a good approach for a first datastore impl.

@pelmenstar1
Copy link
Contributor Author

@alorma Ok, no problem.

BTW, I don't think the use of Jetpack DataStore in a synchronous context is a good idea, because:

  • the disk IO can be really slow
  • no error handling

@pelmenstar1
Copy link
Contributor Author

I'm closing the PR as the implementation of Jetpack DataStore support, which better fits in the current state of the library, has been merged.

@pelmenstar1 pelmenstar1 deleted the jetpack-datastore-support branch August 27, 2022 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants