一个基于react redux typescript saga

作者: 破石头 | 来源:发表于2018-01-07 13:32 被阅读110次

这是一个典型的web应用程序的技术栈,可以在这个项目的基础上开发你想做的应用。前端的开发有开发和产品两种模式,开发模式主要是为了Hot code reloading.

代码在这里:https://github.com/vcycyv/react-redux-typescript-saga-webpack-springboot-jpa-pomotodo 

使用方法:

1. clone/download the project

2. run "gradle wrapper"

3. run "gradle build" (It will download jar files and js modules dependency)

4. Before importing the project into IDE, comment out "//include 'src:main:frontend" from settings.gradle

5. Import gradle project to IDE. (I use eclipse)

6. create a postgre db named "pomotodo"

7. Start the mid-tier by running Application.java

8. UI development 

   8.1 For projection, navigate to /src/main/frontend and run "npm run build", and go to localhost:8080/pomotodo 

   8.2 For development (hot reloading), navigate to /src/main/frontend and run "npm start", and go to localhost:9090 

使用redux-saga的好处是为了side-effect, 比如下面代码中,const tasks = yield call(ApiTasks.listTasks); 调用后端服务, 

export function* listTasks() {

    const tasks = yield call(ApiTasks.listTasks);

    yield put({

        type: LIST_TASK_SUCCESS,

        tasks

    })

}

再下面一行的yield put语句dispatch了LIST_TASK_SUCCESS这个action,payload就是REST API 返回的数据tasks.

计划继续开发这个项目,最终做一个番茄时间管理的工具。感兴趣的朋友可以在github上star 这个项目,下次可以随时在“your star”中找到它。

相关文章

网友评论

    本文标题:一个基于react redux typescript saga

    本文链接:https://www.haomeiwen.com/subject/atnguttx.html