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

Documentation typo? #391

Open
JosepAlacid opened this issue Dec 18, 2019 · 2 comments
Open

Documentation typo? #391

JosepAlacid opened this issue Dec 18, 2019 · 2 comments

Comments

@JosepAlacid
Copy link

I'm not really sure but as for declaration:

export class FeedZebra {
  public static readonly type = '[Animals] Feed zebra';
  constructor(public payload: string) {}
}

can it be used as:

@Action(Add)
public add({ getState, setState }: StateContext<AnimalsStateModel>, (...)

?

or should it be:

@Action(FeedZebra)
public add({ getState, setState }: StateContext<AnimalsStateModel>, (...)

?

or even:

@Action(FeedZebra)
 public feedZebra({ getState, setState }: StateContext<AnimalsStateModel>, (...)

?

@vdiaz1130
Copy link

I removed the parenthesis inside the setState return and got rid of the error below.

  @Action(FeedZebra)
  @ImmutableContext()
  public add({ setState }: StateContext<AnimalsStateModel>, { payload }: FeedZebra): void {
    setState((state: AnimalsStateModel) => { // Removed paren here...
      return state;
    }); // Removed paren here...
  }
}

With the original example (containing parenthesis, I was getting an error in the setState() function:

Argument of type '(state: AnimalsStateModel) => { return: AnimalsStateModel; }' is not assignable to parameter of type 'AnimalsStateModel | StateOperator<AnimalsStateModel>'.
  Type '(state: AnimalsStateModel) => { return: AnimalsStateModel; }' is not assignable to type 'StateOperator<AnimalsStateModel>'.
    Property 'zebra' is missing in type '{ return: AnimalsStateModel; }' but required in type 'AnimalsStateModel'.ts(2345

@splincode
Copy link
Member

please send pull request

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

No branches or pull requests

3 participants