Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6d2d8f0

Browse files
authored
Merge pull request #1538 from rx-angular/standalone-components
feat(template): migrate to standalone API
2 parents 93b71e8 + 07ddf7f commit 6d2d8f0

34 files changed

+652
-732
lines changed

libs/template/experimental/viewport-prio/src/lib/viewport-prio.directive.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,7 @@ import { RxStrategyProvider } from '@rx-angular/cdk/render-strategies';
1111
import { coerceObservableWith } from '@rx-angular/cdk/coercing';
1212
import { RxNotification } from '@rx-angular/cdk/notifications';
1313
import { LetDirective } from '@rx-angular/template/let';
14-
import {
15-
BehaviorSubject,
16-
combineLatest,
17-
Observable,
18-
of,
19-
Subject,
20-
} from 'rxjs';
14+
import { BehaviorSubject, combineLatest, Observable, of, Subject } from 'rxjs';
2115
import { filter, map, mergeAll, withLatestFrom } from 'rxjs/operators';
2216

2317
function intersectionObserver(options?: object): {
@@ -60,6 +54,7 @@ const observerSupported = () =>
6054
*/
6155
// eslint-disable-next-line @angular-eslint/directive-selector
6256
selector: '[viewport-prio]',
57+
standalone: true,
6358
})
6459
export class ViewportPrioDirective implements OnInit, OnDestroy {
6560
// Note that we're picking only the `intersectionRatio` property
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import { NgModule } from '@angular/core';
22
import { ViewportPrioDirective } from './viewport-prio.directive';
33

4-
const DECLARATIONS = [ViewportPrioDirective];
5-
4+
/** @deprecated use the standalone import, will be removed with v16 */
65
@NgModule({
7-
declarations: DECLARATIONS,
8-
exports: DECLARATIONS
6+
imports: [ViewportPrioDirective],
7+
exports: [ViewportPrioDirective],
98
})
10-
export class ViewportPrioModule {
11-
}
9+
export class ViewportPrioModule {}

libs/template/for/src/lib/for.directive.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ declare const ngDevMode: boolean;
7676
*/
7777
@Directive({
7878
selector: '[rxFor][rxForOf]',
79+
standalone: true,
7980
})
8081
// eslint-disable-next-line @angular-eslint/directive-class-suffix
8182
export class RxFor<T, U extends NgIterable<T> = NgIterable<T>>
Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
import { NgModule } from '@angular/core';
22
import { RxFor } from './for.directive';
33

4-
const DECLARATIONS = [
5-
RxFor
6-
];
4+
const EXPORTS = [RxFor];
75

6+
/** @deprecated use the standalone import, will be removed with v16 */
87
@NgModule({
9-
declarations: DECLARATIONS,
10-
imports: [],
11-
exports: DECLARATIONS
8+
imports: EXPORTS,
9+
exports: EXPORTS,
1210
})
13-
export class ForModule {
14-
}
11+
export class ForModule {}

libs/template/for/src/lib/tests/for.directive.observable.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
44
import { By } from '@angular/platform-browser';
55
import { RX_RENDER_STRATEGIES_CONFIG } from '@rx-angular/cdk/render-strategies';
66
import { Observable } from 'rxjs';
7+
import { RxFor } from '../for.directive';
78
import { ForModule } from '../for.module';
89
import {
910
createErrorHandler,
@@ -49,7 +50,7 @@ describe('rxFor with observables', () => {
4950
beforeEach(() => {
5051
TestBed.configureTestingModule({
5152
declarations: [TestComponent],
52-
imports: [CommonModule, ForModule],
53+
imports: [CommonModule, RxFor],
5354
providers: [
5455
{
5556
provide: ErrorHandler,

libs/template/for/src/lib/tests/for.directive.parent-notification.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ describe('rxFor parent-notifications', () => {
7979
beforeEach(() => {
8080
TestBed.configureTestingModule({
8181
declarations: [ParentNotifyTestComponent],
82-
imports: [ForModule],
82+
imports: [RxFor],
8383
teardown: { destroyAfterEach: true },
8484
});
8585
fixture = TestBed.createComponent(ParentNotifyTestComponent);

libs/template/for/src/lib/tests/for.directive.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { ErrorHandler } from '@angular/core';
22
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
33
import { By } from '@angular/platform-browser';
44
import { RX_RENDER_STRATEGIES_CONFIG } from '@rx-angular/cdk/render-strategies';
5+
import { RxFor } from '../for.directive';
56
import { ForModule } from '../for.module';
67
import {
78
createErrorHandler,
@@ -37,7 +38,7 @@ describe('rxFor', () => {
3738
beforeEach(() => {
3839
TestBed.configureTestingModule({
3940
declarations: [TestComponent],
40-
imports: [ForModule],
41+
imports: [RxFor],
4142
providers: [
4243
{
4344
provide: ErrorHandler,

libs/template/for/src/lib/tests/for.directive.strategy.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { ErrorHandler } from '@angular/core';
22
import { ComponentFixture, TestBed } from '@angular/core/testing';
33
import { RxStrategyProvider } from '@rx-angular/cdk/render-strategies';
4+
import { RxFor } from '../for.directive';
45
import { ForModule } from '../for.module';
56
import { createTestComponent, TestComponent } from './fixtures';
67

@@ -24,7 +25,7 @@ describe('rxFor strategies', () => {
2425
beforeEach(() => {
2526
TestBed.configureTestingModule({
2627
declarations: [TestComponent],
27-
imports: [ForModule],
28+
imports: [RxFor],
2829
});
2930
fixture = createTestComponent(
3031
`<div><span *rxFor="let item of items; strategy: strategy; renderCallback: renderedValue$">{{item.toString()}};</span></div>`

libs/template/if/src/lib/if.directive.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ import {
6363
*/
6464
@Directive({
6565
selector: '[rxIf]',
66+
standalone: true,
6667
})
6768
// eslint-disable-next-line @angular-eslint/directive-class-suffix
6869
export class RxIf<T = unknown>

libs/template/if/src/lib/if.module.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { NgModule } from '@angular/core';
22
import { RxIf } from './if.directive';
33

4-
const DECLARATIONS = [RxIf];
4+
const EXPORTS = [RxIf];
55

6+
/** @deprecated use the standalone import, will be removed with v16 */
67
@NgModule({
7-
declarations: DECLARATIONS,
8-
imports: [],
9-
exports: DECLARATIONS,
8+
imports: EXPORTS,
9+
exports: EXPORTS,
1010
})
1111
export class IfModule {}

libs/template/if/src/lib/tests/if.directive.context-templates.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
throwError,
1818
} from 'rxjs';
1919
import { map, take, tap } from 'rxjs/operators';
20+
import { RxIf } from '../if.directive';
2021
import { IfModule } from '../if.module';
2122
import { createTestComponent, TestComponent } from './fixtures';
2223

@@ -70,7 +71,7 @@ const setupTestComponent = () => {
7071
},
7172
},
7273
],
73-
imports: [IfModule],
74+
imports: [RxIf],
7475
});
7576
};
7677

libs/template/if/src/lib/tests/if.directive.context.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
throwError,
1919
} from 'rxjs';
2020
import { map, take, tap } from 'rxjs/operators';
21+
import { RxIf } from '../if.directive';
2122
import { IfModule } from '../if.module';
2223
import { createTestComponent, TestComponent } from './fixtures';
2324

@@ -77,7 +78,7 @@ const setupTestComponent = () => {
7778
},
7879
},
7980
],
80-
imports: [IfModule],
81+
imports: [RxIf],
8182
});
8283
};
8384

0 commit comments

Comments
 (0)