Skip to content

Add a method allowing to retrieve <Action | undefined> by action name #500

@reda-alaoui

Description

@reda-alaoui

As of today, the only way to retrieve an action by name is via the following pattern:

if (state.hasAction('delete')) {
      state.action('delete').submit({});
}

The guard is needed because State#action(string) will throw if there is no action for this name.

Could we provide a method similar to State#action(string) that would return undefined if the action is not found?
That would allow the following pattern:

state.action('delete')?.submit({});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions