Skip to content

withMutation Typing #286

@pablomaurer

Description

@pablomaurer
// store
withMutations((store) => ({
  myMutation: httpMutation((myNum: number) => ({
    url: `/api/register/myMutation/${myNum}`,
    method: 'GET',
    headers: apiHeaders(),
  })),
})),

wrong usage (example 1)

// component
readonly myMutation = this.store.myMutation; // Mutation<number, any>

// html
{{ myMutation.isPending() }}

// runtime error:
ERROR TypeError: ctx.myMutation.isPending is not a function

correct usage (example 2)

// component
readonly myMutationIsPending = this.store.myMutationIsPending;

// html
{{ myMutationIsPending() }}
  • I would love that example 1 would work.
  • The Typings give you the feeling that example 1 should work, but then you end in a runtime error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    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