我继承了使用immutable.js
实现的redux存储(存储对象是Map)。
当我尝试通过pipe
ramda
商店时,它不起作用:
import { pipe, tap } from 'ramda';
it.only('should handle data loading', () => {
const initialState = home(); // it returns map
const fn = pipe(
tap(x => {
console.log('i am inside tap', x);
})
);
console.log('this is initialState', initialState); // prints state to console correctly
fn('wtf'); // works - tap is called
fn(initialState); // does not work - tap is not called
});
你知道为什么fn(initialState)
不工作吗?
tap
似乎有问题。它似乎已在最近几个版本中引入。以下两个片段之间的唯一区别是第一个使用Ramda 0.24而第二个使用Ramda 0.26.1。在那些之间,tap
似乎已经破裂。虽然它适用于某些值,但它不适用于Immutable。
你能和Ramda项目一起raise an issue吗?
const {Map} = immutable
const {tap, pipe, map} = ramda
const square = n => n * n;
const home = () => new Map({foo: 1, bar: 2, baz: 3});
const fn = pipe(
tap(console.log),
map(square),
tap(console.log),
);
const initialState = home();
fn(initialState); // does not work - tap is not called
<script src="https://bundle.run/[email protected]"></script>
<script src="https://bundle.run/[email protected]"></script>
const {Map} = immutable
const {tap, pipe, map} = ramda
const square = n => n * n;
const home = () => new Map({foo: 1, bar: 2, baz: 3});
const fn = pipe(
tap(console.log),
map(square),
tap(console.log),
);
const initialState = home();
fn(initialState); // does not work - tap is not called
<script src="https://bundle.run/[email protected]"></script>
<script src="https://bundle.run/[email protected]"></script>