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

Proposal: Allow onInit/afterViewInit/afterContentInit to return observables #1986

Closed
dummdidumm opened this issue Dec 17, 2019 · 1 comment · Fixed by #2242
Closed

Proposal: Allow onInit/afterViewInit/afterContentInit to return observables #1986

dummdidumm opened this issue Dec 17, 2019 · 1 comment · Fixed by #2242

Comments

@dummdidumm
Copy link

It would be great if formly would support observables on the hooks onInit afterViewInit and afterContentInit. If an observable is returned from one of the hooks, Formly would automatically subscribe to that observable until the field is destroyed. This would free users from subscribing to the observable and handling the onDestroy-hook themselves.

Example usage:

fields = [{
   ...
   hooks: {
      // Patch value of some other form control every time this value changes
      // subscription and unsubscribe is handled by formly
      onInit: field => field.formControl.valueChanges.pipe(
                    tap(value => field.form.patchValue({someOtherField: value})
                 )
   }
 },
...
];
@aitboudad
Copy link
Member

This issue has been fixed and released as part of v5.7 release.

Please let us know, in case you are still encountering a similar issue/problem.
Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

2 participants