Skip to content

Commit c9e1667

Browse files
committed
Add RxManagedTransaction and deprecate commit, rollback and close
1 parent 29ad16f commit c9e1667

File tree

4 files changed

+22
-3
lines changed

4 files changed

+22
-3
lines changed

packages/neo4j-driver/src/session-rx.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { flatMap, catchError, concat } from 'rxjs/operators'
2121
import RxResult from './result-rx'
2222
import { Session, internal } from 'neo4j-driver-core'
2323
import RxTransaction from './transaction-rx'
24+
import RxManagedTransaction from './transaction-managed-rx'
2425
import RxRetryLogic from './internal/retry-logic-rx'
2526

2627
const {
@@ -84,7 +85,7 @@ export default class RxSession {
8485
* Executes the provided unit of work in a {@link READ} reactive transaction which is created with the provided
8586
* transaction configuration.
8687
* @public
87-
* @param {function(txc: RxTransaction): Observable} work - A unit of work to be executed.
88+
* @param {function(txc: RxManagedTransaction): Observable} work - A unit of work to be executed.
8889
* @param {TransactionConfig} transactionConfig - Configuration for the enclosing transaction created by the driver.
8990
* @returns {Observable} - A reactive stream returned by the unit of work.
9091
*/
@@ -96,7 +97,7 @@ export default class RxSession {
9697
* Executes the provided unit of work in a {@link WRITE} reactive transaction which is created with the provided
9798
* transaction configuration.
9899
* @public
99-
* @param {function(txc: RxTransaction): Observable} work - A unit of work to be executed.
100+
* @param {function(txc: RxManagedTransaction): Observable} work - A unit of work to be executed.
100101
* @param {TransactionConfig} transactionConfig - Configuration for the enclosing transaction created by the driver.
101102
* @returns {Observable} - A reactive stream returned by the unit of work.
102103
*/

packages/neo4j-driver/test/types/session-rx.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
} from 'neo4j-driver-core'
2929
import { Observable, of, Observer, throwError } from 'rxjs'
3030
import { concat, finalize, catchError } from 'rxjs/operators'
31+
import RxManagedTransaction from '../../types/transaction-managed-rx'
3132

3233
const dummy: any = null
3334
const intValue: Integer = Integer.fromInt(42)
@@ -152,3 +153,15 @@ const observable6: Observable<number> = rxSession.writeTransaction(
152153
(tx: RxTransaction) => of(42),
153154
txConfig4
154155
)
156+
157+
const observable7: Observable<string> = rxSession.readTransaction(
158+
(tx: RxManagedTransaction) => {
159+
return of('42')
160+
}
161+
)
162+
163+
const observable8: Observable<string> = rxSession.writeTransaction(
164+
(tx: RxManagedTransaction) => {
165+
return of('42')
166+
}
167+
)

packages/neo4j-driver/types/index.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ import {
7474
} from './driver'
7575
import RxSession from './session-rx'
7676
import RxTransaction from './transaction-rx'
77+
import RxManagedTransaction from './transaction-managed-rx'
7778
import RxResult from './result-rx'
7879
import { Parameters } from './query-runner'
7980

@@ -118,6 +119,7 @@ declare const types: {
118119
Integer: typeof Integer
119120
RxSession: RxSession
120121
RxTransaction: RxTransaction
122+
RxManagedTransaction: RxManagedTransaction
121123
RxResult: RxResult
122124
}
123125

@@ -203,6 +205,7 @@ declare const forExport: {
203205
DateTime: DateTime
204206
RxSession: RxSession
205207
RxTransaction: RxTransaction
208+
RxManagedTransaction: RxManagedTransaction
206209
RxResult: RxResult
207210
ConnectionProvider: ConnectionProvider
208211
isDuration: typeof isDuration
@@ -262,6 +265,7 @@ export {
262265
DateTime,
263266
RxSession,
264267
RxTransaction,
268+
RxManagedTransaction,
265269
RxResult,
266270
ConnectionProvider,
267271
isDuration,

packages/neo4j-driver/types/session-rx.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@
1818
*/
1919
import RxResult from './result-rx'
2020
import RxTransaction from './transaction-rx'
21+
import RxManagedTransaction from './transaction-managed-rx'
2122
import { TransactionConfig } from 'neo4j-driver-core'
2223
import { Parameters } from './query-runner'
2324
import { Observable } from 'rxjs'
2425

25-
declare type RxTransactionWork<T> = (tx: RxTransaction) => Observable<T>
26+
declare type RxTransactionWork<T> = (tx: RxManagedTransaction) => Observable<T>
2627

2728
declare interface RxSession {
2829
run(

0 commit comments

Comments
 (0)