@equinor/fusion-framework-module-http
Advanced tools
Comparing version 0.1.0-beta.3 to 0.1.0-beta.4
@@ -1,3 +0,3 @@ | ||
import { BehaviorSubject, from } from 'rxjs'; | ||
import { withLatestFrom, concatMap, last } from 'rxjs/operators'; | ||
import { from } from 'rxjs'; | ||
import { last, mergeScan } from 'rxjs/operators'; | ||
export class ProcessOperators { | ||
@@ -18,9 +18,5 @@ _operators = {}; | ||
process(request) { | ||
const request$ = new BehaviorSubject(request); | ||
from(Object.values(this._operators)) | ||
.pipe(withLatestFrom(request$), concatMap(async ([operator, value]) => (await operator(value)) || value)) | ||
.subscribe(request$); | ||
return request$.pipe(last()); | ||
return from(Object.values(this._operators)).pipe(mergeScan((value, operator) => Promise.resolve(operator(value)).then((x) => x ?? value), request, 1), last()); | ||
} | ||
} | ||
//# sourceMappingURL=process-operators.js.map |
{ | ||
"name": "@equinor/fusion-framework-module-http", | ||
"version": "0.1.0-beta.3", | ||
"version": "0.1.0-beta.4", | ||
"description": "", | ||
@@ -24,3 +24,3 @@ "main": "./dist/esm/index.js", | ||
"dependencies": { | ||
"@equinor/fusion-framework-module": "^0.1.0-beta.3" | ||
"@equinor/fusion-framework-module": "^0.1.0-beta.4" | ||
}, | ||
@@ -35,3 +35,3 @@ "types": "index.d.ts", | ||
}, | ||
"gitHead": "c112e1fd2c1f4c6b3902767c621cb3967c66c357" | ||
"gitHead": "e3857f92b410b4134fa08ffbc791d211a02a3a85" | ||
} |
@@ -1,3 +0,3 @@ | ||
import { BehaviorSubject, from, Observable } from 'rxjs'; | ||
import { withLatestFrom, concatMap, last } from 'rxjs/operators'; | ||
import { from, Observable } from 'rxjs'; | ||
import { last, mergeScan } from 'rxjs/operators'; | ||
@@ -41,11 +41,15 @@ export type ProcessOperator<T, R = T> = (request: T) => R | void | Promise<R | void>; | ||
process(request: T): Observable<T> { | ||
const request$ = new BehaviorSubject<T>(request); | ||
from(Object.values(this._operators)) | ||
.pipe( | ||
withLatestFrom(request$), | ||
concatMap(async ([operator, value]) => (await operator(value)) || value) | ||
) | ||
.subscribe(request$); | ||
return request$.pipe(last()); | ||
return from(Object.values(this._operators)).pipe( | ||
mergeScan( | ||
// resolve current operator and return result or previous if void | ||
(value, operator) => Promise.resolve(operator(value)).then((x) => x ?? value), | ||
// initial value | ||
request, | ||
// only allow concurrency of one operator | ||
1 | ||
), | ||
// output result of last operator | ||
last() | ||
); | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
89309