Skip to content

Commit

Permalink
chore: improve
Browse files Browse the repository at this point in the history
Signed-off-by: waterplea <[email protected]>
  • Loading branch information
waterplea committed Jun 4, 2024
1 parent 7131c2f commit 8f55a4b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions projects/cdk/utils/miscellaneous/directive-binding.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import type {ProviderToken, WritableSignal} from '@angular/core';
import type {ProviderToken, Signal, WritableSignal} from '@angular/core';
import {effect, inject, isSignal, signal} from '@angular/core';

export function tuiDirectiveBinding<T, G extends keyof T, R>(
token: ProviderToken<T>,
key: G,
initial: T[G] extends WritableSignal<R> ? R : T[G],
initial: T[G] extends WritableSignal<R> ? R | Signal<R> : Signal<T[G]> | T[G],
): WritableSignal<typeof initial> {
const result = signal(initial);
const directive = inject(token);
const result: any = isSignal(initial) ? initial : signal(initial);
const directive = inject(token, {self: true});

effect(
() => {
Expand Down
2 changes: 1 addition & 1 deletion projects/cdk/utils/miscellaneous/directive-listener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function tuiDirectiveListener<T, K extends OutputKeysOf<T>>(
token: ProviderToken<T>,
key: K,
): Signal<OutputTypeOf<T[K]>> {
const prop: any = inject(token)[key];
const prop: any = inject(token, {self: true})[key];

return isSignal(prop) ? prop : toSignal<any>(prop);
}

0 comments on commit 8f55a4b

Please sign in to comment.