Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
634 additions
and
426 deletions.
There are no files selected for viewing
22 changes: 13 additions & 9 deletions
22
apps/demos/src/app/features/template/rx-let/rx-let.menu.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,34 +1,38 @@ | ||
export const MENU_ITEMS = [ | ||
{ | ||
label: 'Basic', | ||
link: 'basic' | ||
link: 'basic', | ||
}, | ||
{ | ||
label: 'Scoping', | ||
link: 'scoping', | ||
}, | ||
{ | ||
label: 'Error Handling', | ||
link: 'error-handling' | ||
link: 'error-handling', | ||
}, | ||
{ | ||
label: 'Exception Handling', | ||
link: 'exception-handling' | ||
link: 'exception-handling', | ||
}, | ||
{ | ||
label: 'Http Errors', | ||
link: 'http-errors' | ||
link: 'http-errors', | ||
}, | ||
{ | ||
label: '*ngif hack', | ||
link: 'ng-if-hack' | ||
link: 'ng-if-hack', | ||
}, | ||
{ | ||
label: 'Template Bindings', | ||
link: 'template-bindings' | ||
link: 'template-bindings', | ||
}, | ||
{ | ||
label: 'Preloading Techniques', | ||
link: 'preloading-images' | ||
link: 'preloading-images', | ||
}, | ||
{ | ||
label: 'Lazy Components', | ||
link: 'lazy-components' | ||
} | ||
link: 'lazy-components', | ||
}, | ||
]; |
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
38 changes: 38 additions & 0 deletions
38
apps/demos/src/app/features/template/rx-let/scoping/intermediate.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,38 @@ | ||
import { | ||
AfterContentInit, | ||
ChangeDetectionStrategy, | ||
Component, | ||
ContentChild, | ||
ContentChildren, | ||
Directive, | ||
OnInit, | ||
QueryList, | ||
} from '@angular/core'; | ||
import { startWith } from 'rxjs'; | ||
|
||
@Directive({ | ||
selector: '[rxaContentChild]', | ||
}) | ||
export class ContentChildDirective {} | ||
|
||
@Component({ | ||
selector: 'rxa-content-parent', | ||
template: ` <ng-content></ng-content> `, | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class ContentParent implements AfterContentInit { | ||
// @ContentChildren(ContentChildDirective) children: QueryList<ContentChildDirective>; | ||
@ContentChild(ContentChildDirective) | ||
set child(child: ContentChildDirective) { | ||
console.log('child', child); | ||
} | ||
|
||
ngAfterContentInit() { | ||
/*console.log('contentParent', this.children); | ||
this.children.changes | ||
.pipe(startWith(this.children)) | ||
.subscribe((children) => { | ||
console.log('children', children); | ||
});*/ | ||
} | ||
} |
128 changes: 128 additions & 0 deletions
128
apps/demos/src/app/features/template/rx-let/scoping/rx-let-scoping.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,128 @@ | ||
import { | ||
AfterViewInit, | ||
ChangeDetectionStrategy, | ||
Component, | ||
ElementRef, | ||
QueryList, | ||
ViewChildren, | ||
} from '@angular/core'; | ||
import { LetDirective } from '@rx-angular/template/let'; | ||
import { Subject } from 'rxjs'; | ||
import { map } from 'rxjs/operators'; | ||
|
||
@Component({ | ||
selector: 'rxa-rx-let-poc', | ||
template: ` | ||
<rxa-visualizer> | ||
<div visualizerHeader> | ||
<h2>rxLet SCOPING</h2> | ||
<rxa-strategy-select | ||
(strategyChange)="strategy = $event" | ||
></rxa-strategy-select> | ||
<rxa-value-provider | ||
#v="rxaValueProvider" | ||
[buttons]="true" | ||
></rxa-value-provider> | ||
<button (click)="v.next()" class="mr-1">toggle</button> | ||
<button [unpatch] (click)="v.next()">toggle (unpatched)</button> | ||
</div> | ||
<div class="row w-100"> | ||
<div class="col-sm-3"> | ||
<h3>RxLet</h3> | ||
<rxa-content-parent> | ||
<div | ||
class="dh-embedded-view" | ||
*rxLet=" | ||
v.incremental$; | ||
let value; | ||
parent: withParent; | ||
renderCallback: renderCallback; | ||
strategy: strategy | ||
" | ||
> | ||
<rxa-dirty-check></rxa-dirty-check> | ||
Value: {{ value }} | ||
<div #letChild rxaContentChild></div> | ||
</div> | ||
</rxa-content-parent> | ||
</div> | ||
<div class="col-sm-3"> | ||
<h3>RxLet</h3> | ||
<rxa-content-parent> | ||
<div | ||
class="dh-embedded-view" | ||
*rxLet=" | ||
v.incremental$; | ||
let value; | ||
parent: withParent; | ||
renderCallback: renderCallback; | ||
strategy: strategy | ||
" | ||
> | ||
<rxa-dirty-check></rxa-dirty-check> | ||
Value: {{ value }} | ||
<div #letChild rxaContentChild></div> | ||
</div> | ||
</rxa-content-parent> | ||
</div> | ||
<div class="col-sm-3"> | ||
<h3>RxLet</h3> | ||
<rxa-content-parent> | ||
<div | ||
class="dh-embedded-view" | ||
*rxLet=" | ||
v.incremental$; | ||
let value; | ||
parent: withParent; | ||
renderCallback: renderCallback; | ||
strategy: strategy | ||
" | ||
> | ||
<rxa-dirty-check></rxa-dirty-check> | ||
Value: {{ value }} | ||
<div #letChild rxaContentChild></div> | ||
</div> | ||
</rxa-content-parent> | ||
</div> | ||
<div class="col-sm-3"> | ||
<h3>RxLet</h3> | ||
<rxa-content-parent> | ||
<div | ||
class="dh-embedded-view" | ||
*rxLet=" | ||
v.incremental$; | ||
let value; | ||
parent: withParent; | ||
renderCallback: renderCallback; | ||
strategy: strategy | ||
" | ||
> | ||
<rxa-dirty-check></rxa-dirty-check> | ||
Value: {{ value }} | ||
<div #letChild rxaContentChild></div> | ||
</div> | ||
</rxa-content-parent> | ||
</div> | ||
</div> | ||
</rxa-visualizer> | ||
`, | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class RxLetScopingComponent implements AfterViewInit { | ||
private _renderCalled = 0; | ||
readonly renderCallback = new Subject(); | ||
|
||
@ViewChildren('letChild') letChildren: QueryList<ElementRef>; | ||
|
||
rendered$ = this.renderCallback.pipe(map(() => this._renderCalled++)); | ||
|
||
strategy; | ||
|
||
withParent = true; | ||
|
||
ngAfterViewInit() { | ||
this.letChildren.changes.subscribe((letDirs) => { | ||
console.log('letChildren', letDirs); | ||
}); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
apps/demos/src/app/features/template/rx-let/scoping/rx-let-scoping.module.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,33 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { MatButtonModule } from '@angular/material/button'; | ||
import { RouterModule, Routes } from '@angular/router'; | ||
import { UnpatchEventsModule } from '../../../../rx-angular-pocs/template/directives/unpatch/unpatch-events.module'; | ||
import { DirtyChecksModule } from '../../../../shared/debug-helper/dirty-checks/index'; | ||
import { StrategySelectModule } from '../../../../shared/debug-helper/strategy-select/strategy-select.module'; | ||
import { ValueProvidersModule } from '../../../../shared/debug-helper/value-provider/value-providers.module'; | ||
import { VisualizerModule } from '../../../../shared/debug-helper/visualizer/visualizer.module'; | ||
import { ContentChildDirective, ContentParent } from './intermediate.component'; | ||
import { RxLetScopingComponent } from './rx-let-scoping.component'; | ||
import { LetModule } from '@rx-angular/template/let'; | ||
|
||
const routes: Routes = [ | ||
{ | ||
path: '', | ||
component: RxLetScopingComponent, | ||
}, | ||
]; | ||
|
||
@NgModule({ | ||
declarations: [RxLetScopingComponent, ContentParent, ContentChildDirective], | ||
imports: [ | ||
RouterModule.forChild(routes), | ||
MatButtonModule, | ||
ValueProvidersModule, | ||
UnpatchEventsModule, | ||
StrategySelectModule, | ||
VisualizerModule, | ||
LetModule, | ||
DirtyChecksModule, | ||
], | ||
}) | ||
export class RxLetScopingModule {} |
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
Oops, something went wrong.