程序入口文件添加依赖:

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)

 

 



dispatch a action with a timeout的更多相关文章

  1. [转] How to dispatch a Redux action with a timeout?

    How to dispatch a Redux action with a timeout? Q I have an action that updates notification state of ...

  2. async/await Task Timeout

    async/await Task Timeout 在日常的电脑使用过程中,估计最难以忍受的就是软件界面"卡住""无响应",在我有限的开发生涯中一直都是在挑战 它 ...

  3. [Angular 2] Dispatching Action with Payloads and type to Reducers

    While action types allow you tell your reducer what action it should take, the payload is the data t ...

  4. vuex2.0 基本使用(2) --- mutation 和 action

    我们的项目非常简单,当点击+1按钮的时候,count 加1,点击-1按钮的时候,count 减1. 1, mutation The only way to actually change state ...

  5. 【14】vuex2.0 之 mutation 和 action

    我们的项目非常简单,当点击+1按钮的时候,count 加1,点击-1按钮的时候,count 减1. 1, mutation The only way to actually change state ...

  6. vuex----mutation和action的基本使用

    我们要实现的很简单,就是点击+1的count加一,点击-1的时候count-1 一.mutation 在vue 中,只有mutation 才能改变state.  mutation 类似事件,每一个mu ...

  7. (转)vuex2.0 基本使用(2) --- mutation 和 action

    我们的项目非常简单,当点击+1按钮的时候,count 加1,点击-1按钮的时候,count 减1. 1, mutation The only way to actually change state ...

  8. 06-vue项目02:vuex、Mutation、Action、ElementUI、axios

    1.Vuex 1.为什么使用VueX data从最上面的组件,一层层往下传值,一层层的验证 Vue单向数据流 “中央空调“,代理 VueX 解决数据 传值.. 2.Vuex介绍与安装 (1)Vuex官 ...

  9. 异步action和redux-thunk理解

    异步action一般指的就是异步action创建函数 action创建函数分为同步action创建函数和异步action创建函数 同步action创建函数(最常见的): function reques ...

随机推荐

  1. python引用py文件中文报错

    文件 a.py 中引用文件 b.py 如果文件b.py中包含中文,会报错. 文件hello.py中代码如下: def say_nihao(): print "你好" 文件main. ...

  2. Linux (Centos)操作MySql命令

    1.安装MySql服务端命令: yum install mysql-server yum install mysql-devel 2.安装MySql客户端 yum install mysql 3.启动 ...

  3. leetcode 406

    该算法题就是leetcode 406题, 题目描述: Suppose you have a random list of people standing in a queue. Each person ...

  4. TIJ——Chapter Eleven:Holding Your Objects

    Java Provides a number of ways to hold objects: An array associates numerical indexes to objects. It ...

  5. android Dialog重绘

    String title = ""; if(itemInfo!=null) title = "\n\""+itemInfo.itemSSID+&quo ...

  6. 当display=none时,元素和子元素高度为0的解决办法

    在前端中为了某种需要,我们需要获取display=none的元素或者子元素的实际高度来进行某些处理,然而html对display=none的元素和子元素是不进行渲染的,如果我们没有规定这些元素的高度那 ...

  7. ubuntu16.04.1下的mysql修改默认编码

    在Ubuntu 下配置 Mysql 的字符编码.安装完 Mysql 后,系统默认的字符编码是 latin1 ,输入的是中文,可是输出却是一堆乱码.现在要做的就是把 Mysql的默认字符编码设置为支持中 ...

  8. dr.wondr博士随笔之某古旧非智能机T6XXX 恢复一例

    大家好!欢迎再次来到dr.Wonde的微博! 今次我给大家带来索尼爱立信古董机T650i的取证工作展示! 首先请出今天我们的主角索尼爱立信 T650i>> 然后在工厂模式下,连接设备,看图 ...

  9. mybatis,sql 批量更新

    <update id="update81OrderStatus" parameterType="java.util.Map">    update ...

  10. js使用模板快速填充数据

    1.html <!DOCTYPE html> <html> <head> <title>模板标签</title> </head> ...