小编Bra*_*Xia的帖子

.getDefaultInstance() 和 .newBuilder().build() 之间有区别吗?

在 Kotlin 中使用 gRPC API 执行此操作。这两者有区别吗?

ApiRequest.newBuilder().build()
Run Code Online (Sandbox Code Playgroud)

ApiRequest.getDefaultInstance()
Run Code Online (Sandbox Code Playgroud)

谢谢

kotlin grpc

4
推荐指数
1
解决办法
1199
查看次数

Stripe Payment Intent Id 需要保密吗?

我在我的应用程序中使用 Stripe 进行付款。有两个 ID:payment_method_idpayment_intent_id。我注意到当我尝试对不同的 Stripe 客户使用 payment_method 时,它不允许我,所以我猜这不是那个秘密。payment_intent_ids 是秘密的吗?如果我将每笔交易的 payment_intent_id 存储在数据库中,那么糟糕吗?

java stripe-payments

4
推荐指数
1
解决办法
288
查看次数

通过标签 Kotlin 从内部嵌套协程返回

用例:我有很多操作想要从主线程异步发生,但又彼此并行。

val scope = CoroutineScope(Dispatchers.IO)
val items = // List of items to do something.

scope.launch {
    items.forEach { item ->
        scope.launch {
            if (itemFailsValidation(item)) {
                // Here I want to skip this item but continue the forEach loop.
                return@launch // "There is more than one label with such a name in this" scope"
            }
            doSomethingThatMightTakeABit(item)
         }
     }
}
Run Code Online (Sandbox Code Playgroud)

如果我尝试添加标签,例如inner@scope.launch,编辑器会说“标签是多余的,因为它不能在 ''break''、''Continue'' 或 ''return'' 表达式中引用”

有谁知道这样做的好方法?

asynchronous coroutine kotlin kotlin-coroutines coroutinescope

3
推荐指数
1
解决办法
1882
查看次数