[MST] Loading Data from the Server using lifecycle hook
Let's stop hardcoding our initial state and fetch it from the server instead.
In this lesson you will learn:
- Set up basic data fetching
- Leverage the
afterCreate
lifecycle hook to automatically run any setup logic a model instance needs to do after creation
export const Group = types
.model({
users: types.map(User)
})
.actions(self => ({
// lifecycle hook
afterCreate() {
self.load()
},
load: flow(function* load() {
const response = yield window.fetch(`http://localhost:3001/users`)
applySnapshot(self.users, yield response.json())
})
}))
[MST] Loading Data from the Server using lifecycle hook的更多相关文章
- [转帖]Loading Data into HAWQ
Loading Data into HAWQ Leave a reply Loading data into the database is required to start using it bu ...
- Loading Data into HDFS
How to use a PDI job to move a file into HDFS. Prerequisites In order to follow along with this how- ...
- 使用OGG"Loading data from file to Replicat"的方法应该注意的问题:replicat进程是前台进程
使用OGG的 "Loading data from file to Replicat"的方法应该注意的问题:replicat进程是前台进程 因此.最好是在vncserver中调用该 ...
- OGG "Loading data from file to Replicat"table静态数据同步配置过程
OGG "Loading data from file to Replicat"table静态数据同步配置过程 一个.mgr过程 GGSCI (lei1) 3> view p ...
- Retrieving data from a server
A system includes a server and a controller embedded in a device. Both the server and the embedded c ...
- [React] Update State Based on Props using the Lifecycle Hook getDerivedStateFromProps in React16.3
getDerivedStateFromProps is lifecycle hook introduced with React 16.3 and intended as a replacement ...
- [React] Capture values using the lifecycle hook getSnapshotBeforeUpdate in React 16.3
getSnapshotBeforeUpdate is a lifecycle hook that was introduced with React 16.3. It is invoked right ...
- 6 ways to import data into SQL Server
I’m going to go over some methods to import data from text files into SQL Server today. The particul ...
- Transfer data to SQL Server from SPC-Light with Excel macros
公司的QA检测软件SPC-Light,需要从其中读取一些信息至SQL Server数据库,储存或是做其它分析. 先是在Excel的VBE的工具中,引入一个组件Microsoft ActiveX Dat ...
随机推荐
- 浅谈 Qt 布局那些事
Qt 布局那些事是本文介绍的内容,直接进入主题.GridLayout是一个非常强大的布局管理器,它可以实现很多复杂的布局,名字中暗示它将所有控件放置在类似网格的布局中.^__^GridLayout有两 ...
- 变量命名规范及str类型
变量命名规范: 1.单词之间用_分开 add_num() 2.全局变量,大写 PI,NUMBER() 3.实例变量,以_开头 _example() 4.私有实例变量 __private() 5.普通函 ...
- ajax异步请求获取数据,实现滚动数字的效果。
BackgroundPositionAnimate.js下载 需要导入的js: <script type="text/javascript" src="js/jqu ...
- VUE:UI组件库(Mint UI & Elment)
VUE:UI组件库 常用 1)Mini UI: a 主页:http://mint-ui.github.io/#!/zh-cn b 说明:饿了么开源的基于vue的移动端UI组件库 2)Elment a ...
- STM32 SPI 发送第一个数据不成功问题
STM32的标准库,跟HAL库都是很实用的, 在使用SPI库的过程中一定要注意时序的问题. 我在调试SPI过程中,调试了两个IC,都是用HAL库, 第一个IC没出问题,第二个IC出现了第一次发送数据不 ...
- 2.WHERE中使用=,>,>=,<,<=,<>,!=比较符号
//查询工资大于等于2000的人 select * from person salary >= 2000; //查询名字等于scott的人 select * from per ...
- Jquery-操作select下拉菜单
jQuery获取Select选择的Text和Value: 1. var checkText=jQuery("#select_id").find("option:selec ...
- IOS Sqlite用户界面增删改查案例
1.案例简单介绍 对SQLite操作进行了简单的封装,将对数据表操作转变成对对象的操作,并通过UI界面完毕对用户表的增.删.改.查,执行界面例如以下图所看到的 a 2.项目project文件夹 Use ...
- bzoj3275: Number(最小割)
3275: Number 题目:传送门 题解: 双倍经验@bzoj3158 代码: #include<cstdio> #include<cstring> #include< ...
- BZOJ 3160 FFT+Manacher
思路: 这道题思路好奇怪--. 我们先要知道关于x (x可以是间隙) 对称的有几对字母 显然暴力是n^2的 那怎么办呢 先把所有'a'看成1 'b'看成0 意外的发现 这不就是卷积嘛 再倒过来搞一搞 ...