dispatch a action with a timeout

 程序入口文件添加依赖:

import { createStore, applyMiddleware } from 'redux'
import thunk from 'redux-thunk'
// actions.js

 const hideTip = (dispatch) => {
  setTimeout(() => {
    dispatch(setTip(""))
  }, 1000)
 }

 const showTipWithTimeout = (tip) => {
   return function(dispatch) {
     dispatch(setTip(tip))
     hideTip(dispatch)
   }
 }

export default showTipWithTimeout

//component.js加入

  onShowTipWithTimeout: (tip) => {
    dispatch(actions.showTipWithTimeout(tip))
  }

  //调用

  othes.onShowTipWithTimeout(string)

 

 



上一篇:Android开源框架:Universal-Image-Loader解析(四)TaskProcess


下一篇:Hive表中的NULL值处理