我是网络开发和学习React / Redux的新手,并遵循http://teropa.info/blog/2015/09/10/full-stack-redux-tutorial.html的教程。
我试图理解和混淆我们在下面的代码中使用的take()和skip()方法。我可以理解其用法,但我们从哪里得到它们? JS方法? immutable.js方法?我搜索谷歌几个小时。但没有运气。有人可以帮忙吗?谢谢你的时间:
import { List, Map } from 'immutable';
export function next(state) {
const entries = state.get('entries');
return state.merge({
vote: Map({ pair: entries.take(2)}),
entries: entries.skip(2)
});
}
答案 0 :(得分:3)
http://facebook.github.io/immutable-js/docs/#/Map/take
http://facebook.github.io/immutable-js/docs/#/Map/skip
take()
返回相同类型的新Collection,其中包含此Collection中的第一个数量条目。
示例:take(amount: number): this
skip()
返回相同类型的新Collection,它排除此Collection中的第一个数量条目。
示例:skip(amount: number): this
这是来自不可变的js map函数