Aurelia 2 State plugin action handler `action` parameter

Hi! I am using Aurelia 2 State plugin (ESNext).

I reproced an example from the docs:

// initial-state.js
export const initialState = {
  keywords: '',

// action-handlers.js
export function keywordsHandler(currentState, action) {
  console.log('action:', action);
  return action.type === 'newKeywords'
    ? { ...currentState, keywords: action.value }
    : currentState;

// main.js
import { StateDefaultConfiguration } from '@aurelia/state';
import Aurelia from 'aurelia';
import { keywordsHandler } from './action-handlers';
import { initialState } from './initial-state';
import { MyApp } from './my-app';

Aurelia.register(StateDefaultConfiguration.init(initialState, keywordsHandler))

// my-app.html
  input.dispatch="{ type: 'newKeywords', value: $ }"

Well, whenever I type on the <input>, what I get on console is: “action: newKeywords”, meaning that I am getting action.type instead of action as the second argument to my action handler.

Is there a bug there, or what? Please help.


It’s recently changed here

And will be out in beta-3. Our doc is ahead of our beta release. For now, it’ll be still (state, action, ...params). We will be doing a beta 3 release soon.

1 Like