Action flow control middleware for woowahanjs
- woowahanjs v0.3.0 higher
$ npm install --save-dev woowahan-action-player
import Woowahan from 'woowahan';
import ActionPlayer from 'woowahan-action-player';
const app = new Woowahan();
app.set(ActionPlayer);
import Woowahan from 'woowahan';
import { FETCH_DATA1, FETCH_DATA2 } from './actions';
export default Woowahan.View.create('myView', {
actions: {
fetchGroupName: {
immediate: false,
preventDupliateCall: true, // default false
sequence: true,
tasks: [
{
name: FETCH_DATA1,
params: {
type: 'xxid'
}
},
{
name: FETCH_DATA1,
/**
뷰의 메소드를 문자열 지정 방식도 지원
ex) params: 'buildParams',
**/
params(prev) {
let p = {};
p.subtype = prev.subtype;
return p;
}
}
],
finish: 'fetchDataDone',
error(err) {
console.error(err);
}
},
},
fetchDataDone(results) {
console.log(results[FETCH_DATA1]);
console.log(results[FETCH_DATA2]);
},
onSubmit() {
this.fetchGroupName();
}
});