import { Actor , Action , IMap } from 'iflux2' ; import { OrderedSet , fromJS } from 'immutable' ; export default class ValidateFieldActor extends Actor { defaultState ( ) { return { fields : OrderedSet ( ) } ; } @ Action ( 'validateField' ) validateField ( state , field ) { if ( field === 'all' ) { return state . update ( 'fields' , ( fields ) => fields . merge ( fromJS ( [ 'username' , 'password' , 'confirm' , 'email' , 'qq' ] ) ) ) ; } return state . update ( 'fields' , ( fields ) => { return fields . add ( field ) ; } ) ; } @ Action ( 'reset' ) reset ( state ) { return state . update ( 'fields' , ( fields ) => fields . clear ( ) ) ; } }