Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(form-events): provide optional injector for both form event utils #509

Open
michael-small opened this issue Sep 29, 2024 · 0 comments
Labels
good first issue Good for newcomers

Comments

@michael-small
Copy link
Contributor

I realized that since the util uses toSignal, it should be able to be given an injector optionally.

export function allEventsSignal<T>(
  form: AbstractControl<T>,
  injector?: Injector
): Signal<FormEventData<T>>;
export function allEventsSignal<T>(
  form: AbstractControl,
  injector?: Injector
): Signal<FormEventData<T>>;

export function allEventsSignal<T>(
  form: AbstractControl<T>,
  injector?: Injector
): Signal<FormEventData<T>> {
  return toSignal(allEventsObservable(form), {
    initialValue: {
      value: form.value, // <-- by the way, this will be .getRawValue() in #499
      status: form.status,
      pristine: form.pristine,
      touched: form.touched,
      valid: form.valid,
      invalid: form.invalid,
      pending: form.pending,
      dirty: form.dirty,
      untouched: form.untouched,
    }, injector: injector});
}

Should be easy enough but I have to make test scenarios, and I want to see if anyone else has any injection considerations I haven't accounted for. Thoughts?

@eneajaho eneajaho added the good first issue Good for newcomers label Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants