Skip to content

Commit 9e143b5

Browse files
committed
Hide datastore from public api/add note on thread
1 parent 66b6108 commit 9e143b5

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

firebase-common/src/main/java/com/google/firebase/datastore/DataStore.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import androidx.datastore.preferences.core.MutablePreferences
2323
import androidx.datastore.preferences.core.Preferences
2424
import androidx.datastore.preferences.core.edit
2525
import androidx.datastore.preferences.preferencesDataStore
26+
import com.google.firebase.annotations.concurrent.Background
2627
import kotlinx.coroutines.flow.firstOrNull
2728
import kotlinx.coroutines.runBlocking
2829

@@ -33,6 +34,10 @@ import kotlinx.coroutines.runBlocking
3334
*
3435
* There should only ever be _one_ instance of this class per context and name variant.
3536
*
37+
* Note that most of the methods in this class **block** on the _current_ thread, as to help keep
38+
* parity with existing Java code. Typically, you'd want to dispatch this work to another thread
39+
* like [@Background][Background].
40+
*
3641
* > Do **NOT** use this _unless_ you're bridging Java code. If you're writing new code, or your
3742
* code is in Kotlin, then you should create your own singleton that uses [DataStore] directly.
3843
*
@@ -43,6 +48,8 @@ import kotlinx.coroutines.runBlocking
4348
*
4449
* @property context The [Context] that this data will be saved under.
4550
* @property name What the storage file should be named.
51+
*
52+
* @hide
4653
*/
4754
class DataStorage(val context: Context, val name: String) {
4855
/**
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2023 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
/** @hide */
16+
package com.google.firebase.datastore;

0 commit comments

Comments
 (0)