Skip to content
This repository has been archived by the owner on Nov 12, 2024. It is now read-only.

Commit

Permalink
remove resursion from util/component
Browse files Browse the repository at this point in the history
  • Loading branch information
binarybro committed Jul 28, 2023
1 parent ef7d14e commit ab75df4
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions libs/util/src/lib/component/with-component-ref.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
import { ComponentRef } from '@angular/core';

/**
* Type-safely assign values to your ComponentRef<T>'s @Input decorated properties.
* You can also chain input assignments
*
* @example
* setComponentRefInput(componenRef).setInput(key, value).setInput(key, value)...
* Type-safely assign values to your ComponentRef's @Input decorated properties.
*/
export function withComponentRef<T>(ref: ComponentRef<T>) {
const setInput = <K extends keyof T & string>(key: K, value: T[K]) => {
ref.setInput(key, value);
return { setInput };
};

return { setInput };
export function setComponentRefInput<T, K extends keyof T & string>(
ref: ComponentRef<T>,
key: K,
value: T[K]
): void {
ref.setInput(key, value);
}

0 comments on commit ab75df4

Please sign in to comment.