From cd3316114ac0921d2e860603ddf1a41f2deb970e Mon Sep 17 00:00:00 2001 From: Michael Berger Date: Mon, 6 Jan 2025 06:57:29 +0100 Subject: [PATCH 1/3] fix(demos): fix wrong property assignment in NgIfHackRxLetComponent --- .../template/rx-let/ng-if-hack/ng-if-hack-rx-let.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/demos/src/app/features/template/rx-let/ng-if-hack/ng-if-hack-rx-let.component.ts b/apps/demos/src/app/features/template/rx-let/ng-if-hack/ng-if-hack-rx-let.component.ts index 28d3940e39..d2bd683d39 100644 --- a/apps/demos/src/app/features/template/rx-let/ng-if-hack/ng-if-hack-rx-let.component.ts +++ b/apps/demos/src/app/features/template/rx-let/ng-if-hack/ng-if-hack-rx-let.component.ts @@ -19,7 +19,7 @@ import { ChangeDetectionStrategy, Component } from '@angular/core'; let value; suspense: suspenseView; error: errorView; - rxComplete: completeView + complete: completeView " > value: {{ value | json }}
From f2826f2db223c0f862d1ae528e111d1c6d2c19e5 Mon Sep 17 00:00:00 2001 From: Michael Berger Date: Mon, 6 Jan 2025 06:59:26 +0100 Subject: [PATCH 2/3] fix(demos): instantiate new rxState instance in injection context --- .../primitives-provider.service.ts | 38 +++++++++++++------ 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/apps/demos/src/app/shared/debug-helper/value-provider/primitives-provider.service.ts b/apps/demos/src/app/shared/debug-helper/value-provider/primitives-provider.service.ts index f26c78a69d..9970d7dfd9 100644 --- a/apps/demos/src/app/shared/debug-helper/value-provider/primitives-provider.service.ts +++ b/apps/demos/src/app/shared/debug-helper/value-provider/primitives-provider.service.ts @@ -1,13 +1,26 @@ -import { ChangeDetectorRef, Injectable } from '@angular/core'; +import { + ChangeDetectorRef, + inject, + Injectable, + Injector, + runInInjectionContext, +} from '@angular/core'; import { RxState } from '@rx-angular/state'; import { merge, Observable, Subject } from 'rxjs'; import { map, scan } from 'rxjs/operators'; import { ngInputFlatten } from '../../utils/ngInputFlatten'; import { ProvidedValues } from './model'; -import { toBoolean, toImgUrl, toInt, toRandom, withCompleteAndError } from './utils'; +import { + toBoolean, + toImgUrl, + toInt, + toRandom, + withCompleteAndError, +} from './utils'; @Injectable() export class PrimitivesProviderService { + private injector = inject(Injector); protected outerChanges = new Subject>(); protected nextSubject = new Subject(); @@ -16,7 +29,7 @@ export class PrimitivesProviderService { protected error$ = this.errorSubject.pipe( map((_) => { throw new Error('ERROR'); - }) + }), ); protected completeSubject = new Subject(); protected resetSubject = new Subject(); @@ -47,31 +60,34 @@ export class PrimitivesProviderService { private resetObservables = () => { this.state.ngOnDestroy(); - this.state = new RxState(); + runInInjectionContext( + this.injector, + () => (this.state = new RxState()), + ); this.state.connect( 'random', merge(this.nextSubject, this.outerChanges.pipe(ngInputFlatten())).pipe( - map(toRandom) - ) + map(toRandom), + ), ); this.float$ = this.state.select('random'); this.int$ = this.state.select( map((s) => toInt(s.random, this.min, this.max)), - withCompleteAndError(this.error$, this.completeSubject) + withCompleteAndError(this.error$, this.completeSubject), ); this.incremental$ = this.state.select( scan((inc) => ++inc, 0), - withCompleteAndError(this.error$, this.completeSubject) + withCompleteAndError(this.error$, this.completeSubject), ); this.boolean$ = this.state.select( map((s) => toBoolean(s.random, this.truthy)), - withCompleteAndError(this.error$, this.completeSubject) + withCompleteAndError(this.error$, this.completeSubject), ); this.imgUrl$ = this.state.select( map((s) => toImgUrl(s.random)), - withCompleteAndError(this.error$, this.completeSubject) + withCompleteAndError(this.error$, this.completeSubject), ); this.state.hold(this.float$, this.updateStatic); @@ -86,7 +102,7 @@ export class PrimitivesProviderService { constructor( protected state: RxState, - protected cdRef: ChangeDetectorRef + protected cdRef: ChangeDetectorRef, ) { this.resetAll(); } From a7a95fce2823932d866de3f6f9c1319ff5ed7abb Mon Sep 17 00:00:00 2001 From: Michael Berger Date: Mon, 6 Jan 2025 07:00:03 +0100 Subject: [PATCH 3/3] refactor(demos): remove unused RxIf --- .../virtual-for-reverse-infinite-scroll.component.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/demos/src/app/features/template/rx-virtual-for/virtual-rendering/virtual-for-reverse-infinite-scroll.component.ts b/apps/demos/src/app/features/template/rx-virtual-for/virtual-rendering/virtual-for-reverse-infinite-scroll.component.ts index 2de8ac0f7e..64baef54a6 100644 --- a/apps/demos/src/app/features/template/rx-virtual-for/virtual-rendering/virtual-for-reverse-infinite-scroll.component.ts +++ b/apps/demos/src/app/features/template/rx-virtual-for/virtual-rendering/virtual-for-reverse-infinite-scroll.component.ts @@ -200,7 +200,6 @@ import { Message, MessageService } from './messages/messages.service'; DatePipe, MatButtonToggleModule, MatInputModule, - RxIf, RxLet, StrategySelectModule, FixedSizeVirtualScrollStrategy,