This repository has been archived by the owner on Nov 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enable importedComponentReady() hook to support Observables, Signals …
…in addition to Promises (#20)
- Loading branch information
Showing
20 changed files
with
158 additions
and
56 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
1 change: 0 additions & 1 deletion
1
libs/imports-orchestrator-examples-static/after-view-init/src/index.ts
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
...iew-init/src/lib/imports-orchestrator-examples-static-after-view-init-home.component.html
This file was deleted.
Oops, something went wrong.
23 changes: 0 additions & 23 deletions
23
...-view-init/src/lib/imports-orchestrator-examples-static-after-view-init-home.component.ts
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
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
3 changes: 3 additions & 0 deletions
3
libs/imports-orchestrator-examples-static/deferred/src/index.ts
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,3 @@ | ||
export * from './lib/deferred-promise.component'; | ||
export * from './lib/deferred-observable.component'; | ||
export * from './lib/deferred-signal.component'; |
26 changes: 26 additions & 0 deletions
26
libs/imports-orchestrator-examples-static/deferred/src/lib/deferred-observable.component.ts
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,26 @@ | ||
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { BehaviorSubject, delay, Observable } from 'rxjs'; | ||
import { ImportedComponentReady } from '@lotto24-angular/imports-orchestrator'; | ||
|
||
@Component({ | ||
selector: 'imports-orchestrator-examples-static-deferred-component', | ||
standalone: true, | ||
imports: [CommonModule], | ||
template: `<div>Deferred: Observable</div>`, | ||
styles: [], | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class DeferredObservableComponent | ||
implements OnInit, ImportedComponentReady | ||
{ | ||
private readonly readySubject = new BehaviorSubject(false); | ||
|
||
public ngOnInit(): void { | ||
this.readySubject.next(true); | ||
} | ||
|
||
public importedComponentReady(): Observable<boolean> { | ||
return this.readySubject.pipe(delay(3000)); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
libs/imports-orchestrator-examples-static/deferred/src/lib/deferred-promise.component.ts
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,19 @@ | ||
import { ChangeDetectionStrategy, Component } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { ImportedComponentReady } from '@lotto24-angular/imports-orchestrator'; | ||
|
||
@Component({ | ||
selector: 'imports-orchestrator-examples-static-deferred-component', | ||
standalone: true, | ||
imports: [CommonModule], | ||
template: `<div>Deferred: Promise</div>`, | ||
styles: [], | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class DeferredPromiseComponent implements ImportedComponentReady { | ||
public importedComponentReady(): Promise<void> { | ||
return new Promise((resolve) => { | ||
setTimeout(resolve, 3000); | ||
}); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
libs/imports-orchestrator-examples-static/deferred/src/lib/deferred-signal.component.ts
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,31 @@ | ||
import { | ||
ChangeDetectionStrategy, | ||
Component, | ||
OnInit, | ||
signal, | ||
Signal, | ||
} from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { ImportedComponentReady } from '@lotto24-angular/imports-orchestrator'; | ||
|
||
@Component({ | ||
selector: 'imports-orchestrator-examples-static-deferred-component', | ||
standalone: true, | ||
imports: [CommonModule], | ||
template: `<div>Deferred: Signal</div>`, | ||
styles: [], | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class DeferredSignalComponent implements OnInit, ImportedComponentReady { | ||
private readonly ready = signal(false); | ||
|
||
public ngOnInit(): void { | ||
setTimeout(() => { | ||
this.ready.set(true); | ||
}, 3000); | ||
} | ||
|
||
public importedComponentReady(): Signal<boolean> { | ||
return this.ready; | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
5 changes: 4 additions & 1 deletion
5
libs/imports-orchestrator/src/lib/resolve/imported-component-ready.interface.ts
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 |
---|---|---|
@@ -1,6 +1,9 @@ | ||
import { Signal } from '@angular/core'; | ||
import {Observable} from "rxjs"; | ||
|
||
/** | ||
* When implementing this interface, the queue will be interrupted until the promise returned by importedComponentReady resolves. | ||
*/ | ||
export interface ImportedComponentReady { | ||
importedComponentReady(): Promise<void>; | ||
importedComponentReady(): Promise<void> | Observable<boolean> | Signal<boolean>; | ||
} |
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,7 @@ | ||
export function assertPromise(type: any): type is Promise<any> { | ||
return ( | ||
type.then !== undefined && | ||
type.catch !== undefined && | ||
type.finally !== undefined | ||
); | ||
} |
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,5 @@ | ||
import { isSignal } from '@angular/core'; | ||
|
||
export function assertSignal(type: any) { | ||
return isSignal(type); | ||
} |
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 |
---|---|---|
@@ -1,2 +1,4 @@ | ||
export * from './assert-observable' | ||
export * from './assert-promise' | ||
export * from './assert-signal' | ||
export * from './assert-standalone' |
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