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))
.app(MyApp)
.start();
// my-app.html
<input
value.state="keywords"
input.dispatch="{ type: 'newKeywords', value: $event.target.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.
Thanks!