Skip to content

Commit

Permalink
Change the disposable wrapper to not depend on RxJava 3 internals
Browse files Browse the repository at this point in the history
  • Loading branch information
akarnokd committed Nov 22, 2021
1 parent bb66cdd commit ca8bcc1
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 17 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ RxJava 3: [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.
```groovy
dependencies {
implementation "com.github.akarnokd:rxjava3-bridge:3.0.1"
implementation "com.github.akarnokd:rxjava3-bridge:3.0.2"
}
```

Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
GROUP=com.github.akarnokd
VERSION_NAME=3.0.1
version=3.0.1
VERSION_NAME=3.0.2
version=3.0.2

POM_ARTIFACT_ID=rxjava3-bridge
POM_NAME=RxJava 3 Bridge to/from RxJava 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,8 @@ public void dispose() {
}

static io.reactivex.rxjava3.disposables.Disposable wrap(io.reactivex.disposables.Disposable disposable) {
if (disposable == io.reactivex.internal.disposables.DisposableHelper.DISPOSED) {
return io.reactivex.rxjava3.internal.disposables.DisposableHelper.DISPOSED;
}
if (disposable == io.reactivex.internal.disposables.EmptyDisposable.INSTANCE) {
return io.reactivex.rxjava3.internal.disposables.EmptyDisposable.INSTANCE;
if (disposable.isDisposed()) {
return io.reactivex.rxjava3.disposables.Disposable.disposed();
}
return new DisposableV2toV3(disposable);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,8 @@ public void dispose() {
}

static io.reactivex.disposables.Disposable wrap(io.reactivex.rxjava3.disposables.Disposable disposable) {
if (disposable == io.reactivex.rxjava3.internal.disposables.DisposableHelper.DISPOSED) {
return io.reactivex.internal.disposables.DisposableHelper.DISPOSED;
}
if (disposable == io.reactivex.rxjava3.internal.disposables.EmptyDisposable.INSTANCE) {
return io.reactivex.internal.disposables.EmptyDisposable.INSTANCE;
if (disposable.isDisposed()) {
return io.reactivex.disposables.Disposables.disposed();
}
return new DisposableV3toV2(disposable);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -501,15 +501,15 @@ public void disposableV2toV3InternalDisposed() {
io.reactivex.disposables.Disposable empty = io.reactivex.internal.disposables.DisposableHelper.DISPOSED;
io.reactivex.rxjava3.disposables.Disposable disposable = RxJavaBridge.toV3Disposable(empty);

assertSame(disposable, io.reactivex.rxjava3.internal.disposables.DisposableHelper.DISPOSED);
assertSame(disposable, io.reactivex.rxjava3.disposables.Disposable.disposed());
}

@Test
public void disposableV2toV3InternalEmpty() {
io.reactivex.disposables.Disposable empty = io.reactivex.internal.disposables.EmptyDisposable.INSTANCE;
io.reactivex.rxjava3.disposables.Disposable disposable = RxJavaBridge.toV3Disposable(empty);

assertSame(disposable, io.reactivex.rxjava3.internal.disposables.EmptyDisposable.INSTANCE);
assertSame(disposable, io.reactivex.rxjava3.disposables.Disposable.disposed());
}

@Test
Expand All @@ -531,15 +531,15 @@ public void disposableV3toV2InternalDisposed() {
io.reactivex.rxjava3.disposables.Disposable empty = io.reactivex.rxjava3.internal.disposables.DisposableHelper.DISPOSED;
io.reactivex.disposables.Disposable disposable = RxJavaBridge.toV2Disposable(empty);

assertSame(disposable, io.reactivex.internal.disposables.DisposableHelper.DISPOSED);
assertSame(disposable, io.reactivex.disposables.Disposables.disposed());
}

@Test
public void disposableV3toV2InternalEmpty() {
io.reactivex.rxjava3.disposables.Disposable empty = io.reactivex.rxjava3.internal.disposables.EmptyDisposable.INSTANCE;
io.reactivex.disposables.Disposable disposable = RxJavaBridge.toV2Disposable(empty);

assertSame(disposable, io.reactivex.internal.disposables.EmptyDisposable.INSTANCE);
assertSame(disposable, io.reactivex.disposables.Disposables.disposed());
}

// -----------------------------------------------------------
Expand Down

0 comments on commit ca8bcc1

Please sign in to comment.