import sleep from 'sleep-promise' ; import { cloneModel , defineModel } from '../../src' ; const initialState = { count : 0 , hello : 'world' , } ; export const basicModel = defineModel ( 'basic' , { initialState , actions : { plus ( state , step ) { state . count += step ; } , minus ( state , step ) { state . count -= step ; } , moreParams ( state , step , hello ) { state . count += step ; state . hello += ', ' + hello ; } , set ( state , count ) { state . count = count ; } , reset ( ) { return this . initialState ; } , _actionIsPrivate ( ) { } , ____alsoPrivateAction ( ) { } , } , effects : { async foo ( hello , step ) { await sleep ( 20 ) ; this . setState ( ( state ) => { state . count += step ; state . hello = hello ; } ) ; return 'OK' ; } , setWithoutFn ( step ) { this . setState ( { count : step , hello : 'earth' , } ) ; } , async bar ( ) { return this . foo ( '' , 100 ) ; } , async bos ( ) { return this . plus ( 4 ) ; } , async hasError ( msg = 'my-test' ) { throw new Error ( msg ) ; } , async pureAsync ( ) { await sleep ( 300 ) ; return 'OK' ; } , normalMethod ( ) { return 'YES' ; } , async _effectIsPrivate ( ) { } , ____alsoPrivateEffect ( ) { this . _effectIsPrivate ; this . _actionIsPrivate ; this . ____alsoPrivateAction ; } , } , } ) ; export const basicSkipRefreshModel = cloneModel ( 'basicSkipRefresh' , basicModel , { skipRefresh : true , } ) ;