Skip to content

Signal Forms: Allow Observable as return type of FormSubmitOptions.action #67827

@eiswind

Description

@eiswind

Which @angular/* package(s) are relevant/related to the feature request?

forms

Description

when using the angulat httpclient to submit a form we have to do something very ugly like

action: async (form) => {
        try {
            await firstValueFrom(this.authService.registerUser(form().value()));
            this.router.navigate(['/login']);
            return undefined;
        } catch (_) {
            return {
                kind: 'server',
                message: 'Something went wrong. Please try again.',
            } satisfies ValidationError.WithOptionalFieldTree;
        }
    },

Proposed solution

When using a generated httpclient for e.g. the one from openapi generator or when using angulars httpclient in general to submit the form to a backend it would be only convenient and in the tradition of angular to return an observable from the action.

Alternatives considered

using firstValueFrom does work, but doen't feel like angular native

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: formsgemini-triagedLabel noting that an issue has been triaged by gemini

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions