-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(presentation): support references in location resolver selections (…
…#1652) * fix(presentation): support references in location resolver selections * fix(presentation): remove unused hook
- Loading branch information
Showing
6 changed files
with
200 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { | ||
combineLatest, | ||
from, | ||
isObservable, | ||
map, | ||
mergeAll, | ||
Observable, | ||
of, | ||
scan, | ||
switchMap, | ||
} from 'rxjs' | ||
|
||
type Props<K extends keyof any, T> = { | ||
[P in K]: T | Observable<T> | ||
} | ||
|
||
function keysOf<T extends object>(value: T) { | ||
return Object.keys(value) as (keyof T)[] | ||
} | ||
|
||
function setKey(source: Record<string, unknown>, key: any, value: unknown) { | ||
return { | ||
...source, | ||
[key]: value, | ||
} | ||
} | ||
|
||
export function props<K extends keyof any, T>(options: {wait?: boolean} = {}) { | ||
return (source: Observable<Props<K, T>>): Observable<Record<string, unknown>> => { | ||
return new Observable<Props<K, T>>((observer) => source.subscribe(observer)).pipe( | ||
switchMap((object) => { | ||
const keyObservables = keysOf(object).map((key) => { | ||
const value = object[key] | ||
return isObservable(value) ? from(value).pipe(map((val) => [key, val])) : of([key, value]) | ||
}) | ||
|
||
return options.wait | ||
? combineLatest(keyObservables).pipe( | ||
map((pairs) => pairs.reduce((acc, [key, value]) => setKey(acc, key, value), {})), | ||
) | ||
: from(keyObservables).pipe( | ||
mergeAll(), | ||
scan((acc, [key, value]) => setKey(acc, key, value), {}), | ||
) | ||
}), | ||
) | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.