Refactored instant loading and some other components

This commit is contained in:
squidfunk
2021-02-12 12:12:49 +01:00
parent 884330da3b
commit 9c9ea8a64d
33 changed files with 463 additions and 150 deletions

View File

@@ -64,14 +64,14 @@ export interface Dialog {
* Watch options
*/
interface WatchOptions {
message$: Subject<string> /* Message subject */
alert$: Subject<string> /* Alert subject */
}
/**
* Mount options
*/
interface MountOptions {
message$: Subject<string> /* Message subject */
alert$: Subject<string> /* Alert subject */
}
/* ----------------------------------------------------------------------------
@@ -87,9 +87,9 @@ interface MountOptions {
* @returns Dialog observable
*/
export function watchDialog(
_el: HTMLElement, { message$ }: WatchOptions
_el: HTMLElement, { alert$ }: WatchOptions
): Observable<Dialog> {
return message$
return alert$
.pipe(
switchMap(message => merge(
of(true),
@@ -111,7 +111,7 @@ export function watchDialog(
* @returns Dialog component observable
*/
export function mountDialog(
el: HTMLElement, { message$ }: MountOptions
el: HTMLElement, options: MountOptions
): Observable<Component<Dialog>> {
const internal$ = new Subject<Dialog>()
internal$
@@ -127,7 +127,7 @@ export function mountDialog(
})
/* Create and return component */
return watchDialog(el, { message$ })
return watchDialog(el, options)
.pipe(
tap(internal$),
finalize(() => internal$.complete()),