Skip to content

Commit

Permalink
fix(component): remove class-level generic from PushPipe (#3127)
Browse files Browse the repository at this point in the history
Closes #3114 

BREAKING CHANGES:

PushPipe no longer has a class-level generic type parameter.

BEFORE:

Use of PushPipe outside of component templates required a generic

AFTER:

Use of PushPipe outside of component templates no longer requires a generic
  • Loading branch information
markostanimirovic authored Nov 2, 2021
1 parent 5ed3c3d commit 548c72c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion modules/component/spec/push/push.pipe.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { EMPTY, NEVER, Observable, ObservableInput, of } from 'rxjs';
import { PushPipe } from '../../src/push/push.pipe';
import { MockChangeDetectorRef } from '../fixtures/fixtures';

let pushPipe: PushPipe<unknown>;
let pushPipe: PushPipe;

function wrapWithSpace(str: string): string {
return ' ' + str + ' ';
Expand Down
16 changes: 7 additions & 9 deletions modules/component/src/push/push.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,26 +54,24 @@ import { createRender } from '../core/cd-aware/creator_render';
* @publicApi
*/
@Pipe({ name: 'ngrxPush', pure: false })
export class PushPipe<S> implements PipeTransform, OnDestroy {
private renderedValue: S | null | undefined;
export class PushPipe implements PipeTransform, OnDestroy {
private renderedValue: unknown;

private readonly subscription: Unsubscribable;
private readonly cdAware: CdAware<S | null | undefined>;
private readonly cdAware: CdAware<unknown>;
private readonly resetContextObserver: NextObserver<void> = {
next: () => (this.renderedValue = undefined),
};
private readonly updateViewContextObserver: NextObserver<
S | null | undefined
> = {
next: (value: S | null | undefined) => (this.renderedValue = value),
private readonly updateViewContextObserver: NextObserver<unknown> = {
next: (value) => (this.renderedValue = value),
};

constructor(
cdRef: ChangeDetectorRef,
ngZone: NgZone,
errorHandler: ErrorHandler
) {
this.cdAware = createCdAware<S>({
this.cdAware = createCdAware({
render: createRender({ cdRef, ngZone }),
updateViewContextObserver: this.updateViewContextObserver,
resetContextObserver: this.resetContextObserver,
Expand All @@ -89,7 +87,7 @@ export class PushPipe<S> implements PipeTransform, OnDestroy {
potentialObservable: ObservableInput<T> | null | undefined
): T | null | undefined {
this.cdAware.nextPotentialObservable(potentialObservable);
return this.renderedValue as any;
return this.renderedValue as T | null | undefined;
}

ngOnDestroy(): void {
Expand Down

0 comments on commit 548c72c

Please sign in to comment.