fix: subscription streams

This commit is contained in:
liyasthomas
2021-12-12 06:19:58 +05:30
parent 67002a204e
commit 534fe8030f
4 changed files with 78 additions and 52 deletions

View File

@@ -1,6 +1,6 @@
import { cloneDeep } from "lodash"
import isEqual from "lodash/isEqual"
import { combineLatest } from "rxjs"
import { combineLatest, Observable } from "rxjs"
import { distinctUntilChanged, map, pluck } from "rxjs/operators"
import DispatchingStore, {
defineDispatchers,
@@ -285,17 +285,22 @@ export const currentEnvironment$ = combineLatest([
})
)
type AggregateEnvironment = {
key: string
value: string
sourceEnv: string
}
/**
* Stream returning all the environment variables accessible in
* the current state (Global + The Selected Environment).
* NOTE: The source environment attribute will be "Global" for Global Env as source.
*/
export const aggregateEnvs$ = combineLatest([
currentEnvironment$,
globalEnv$,
]).pipe(
export const aggregateEnvs$: Observable<AggregateEnvironment[]> = combineLatest(
[currentEnvironment$, globalEnv$]
).pipe(
map(([selectedEnv, globalVars]) => {
const results: { key: string; value: string; sourceEnv: string }[] = []
const results: AggregateEnvironment[] = []
selectedEnv.variables.forEach(({ key, value }) =>
results.push({ key, value, sourceEnv: selectedEnv.name })