Kshitij Patil
01/16/2021, 10:40 AMDataStore
classes Singleton or not? I was trying to achieve a behavior where if you change IP address from settings fragment, all the subsequent network calls should be made with updated IP. I tried to use preferences Flow variables to update repository variable but this isn't workingPaul Woitaschek
01/16/2021, 11:25 AMPaul Woitaschek
01/16/2021, 11:25 AM/**
* Create an instance of SingleProcessDataStore. Never create more than one instance of
* DataStore for a given file; doing so can break all DataStore functionality. You should
* consider managing your DataStore instance as a singleton.
*
* T is the type DataStore acts on. The type T must be immutable. Mutating a type used in
* DataStore invalidates any guarantees that DataStore provides and will result in
* potentially serious, hard-to-catch bugs. We strongly recommend using protocol buffers:
* <https://developers.google.com/protocol-buffers/docs/javatutorial> - which provides
* immutability guarantees, a simple API and efficient serialization.
*
* @param serializer Serializer for the type T used with DataStore. The type T must be immutable.
* @param corruptionHandler The corruptionHandler is invoked if DataStore encounters a
* [CorruptionException] when attempting to read data. CorruptionExceptions are thrown by
* serializers when data can not be de-serialized.
* @param migrations Migrations are run before any access to data can occur. Migrations must
* be idempotent.
* @param scope The scope in which IO operations and transform functions will execute.
* @param produceFile Function which returns the file that the new DataStore will act on. The
* function must return the same path every time. No two instances of DataStore should act on
* the same file at the same time.
*
* @return a new DataStore instance with the provided configuration
*/
Paul Woitaschek
01/16/2021, 11:25 AMNever create more than one instance of
* DataStore for a given file; doing so can break all DataStore functionality. You should
* consider managing your DataStore instance as a singleton.