Skip to content

Commit efb0007

Browse files
fabriziocuccifacebook-github-bot
authored andcommitted
Kotlinify LinearCountingRetryPolicy (#43871)
Summary: Pull Request resolved: #43871 Changelog: [Internal] As part of the Sustainability Week (see [post](https://fb.workplace.com/groups/251759413609061/permalink/742797531171911/)). Reviewed By: alanleedev Differential Revision: D55753695 fbshipit-source-id: 4a46b02b2dd18981968371a94d2fa07af90fc74e
1 parent 7cffdf2 commit efb0007

3 files changed

Lines changed: 32 additions & 49 deletions

File tree

packages/react-native/ReactAndroid/api/ReactAndroid.api

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2899,7 +2899,7 @@ public abstract interface class com/facebook/react/jstasks/HeadlessJsTaskRetryPo
28992899
public abstract fun update ()Lcom/facebook/react/jstasks/HeadlessJsTaskRetryPolicy;
29002900
}
29012901

2902-
public class com/facebook/react/jstasks/LinearCountingRetryPolicy : com/facebook/react/jstasks/HeadlessJsTaskRetryPolicy {
2902+
public final class com/facebook/react/jstasks/LinearCountingRetryPolicy : com/facebook/react/jstasks/HeadlessJsTaskRetryPolicy {
29032903
public fun <init> (II)V
29042904
public fun canRetry ()Z
29052905
public fun copy ()Lcom/facebook/react/jstasks/HeadlessJsTaskRetryPolicy;

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/jstasks/LinearCountingRetryPolicy.java

Lines changed: 0 additions & 48 deletions
This file was deleted.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
package com.facebook.react.jstasks
9+
10+
public class LinearCountingRetryPolicy(
11+
private val retryAttempts: Int,
12+
private val delayBetweenAttemptsInMs: Int
13+
) : HeadlessJsTaskRetryPolicy {
14+
15+
override public fun canRetry(): Boolean = retryAttempts > 0
16+
17+
override public fun getDelay(): Int = delayBetweenAttemptsInMs
18+
19+
override public fun update(): HeadlessJsTaskRetryPolicy {
20+
val remainingRetryAttempts = retryAttempts - 1
21+
22+
return if (remainingRetryAttempts > 0) {
23+
LinearCountingRetryPolicy(remainingRetryAttempts, delayBetweenAttemptsInMs)
24+
} else {
25+
NoRetryPolicy.INSTANCE
26+
}
27+
}
28+
29+
override public fun copy(): HeadlessJsTaskRetryPolicy =
30+
LinearCountingRetryPolicy(retryAttempts, delayBetweenAttemptsInMs)
31+
}

0 commit comments

Comments
 (0)