在 ImmutableJS 中用 Iterable 替换 Map
Replacing Map with Iterable in ImmutableJS
我有这段代码,我想在 ImmutableJS 中转换为 A 序列或 Iterable。谁能告诉我结果会怎样?
import { INCREMENT } from '../actionTypes/default'
import { Map } from 'immutable'
const INCREASE_NUMBER = (state = Map({ number: 0}), action) => {
switch(action.type) {
case INCREMENT:
return state.update('number', num => num + 1 )
default:
return state
}
};
module.exports = INCREASE_NUMBER
Iterable已经是Map的一个实例,解决了!
我有这段代码,我想在 ImmutableJS 中转换为 A 序列或 Iterable。谁能告诉我结果会怎样?
import { INCREMENT } from '../actionTypes/default'
import { Map } from 'immutable'
const INCREASE_NUMBER = (state = Map({ number: 0}), action) => {
switch(action.type) {
case INCREMENT:
return state.update('number', num => num + 1 )
default:
return state
}
};
module.exports = INCREASE_NUMBER
Iterable已经是Map的一个实例,解决了!