Skip to content

dispatch in state #547

Description

@chestongo

For the @ImmutableContext() you can use setState, but if you want to use dispatch as well... how do you combine this?

  @Action(SetAutocompleteRequest, { cancelUncompleted: true })
  @ImmutableContext()
  setAutocompleteRequest({setState, dispatch}: StateContext<ITrialState>, {payload}: SetAutocompleteRequest) {
    return this.autocompleteService.postAutocomplete(payload, 5).pipe(
      tap(response => {
        setState((state: ITrialState) => {
          state.autocompleteRequest = {...payload};
          return state;
        });
        // dispatch(
        //   new SetAutocompleteResponse(response)
        // );
      })
    )
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions