frp-ts
frp-ts copied to clipboard
feat(core): add distinctUntilChanged operator
☁️ Nx Cloud Report
We didn't find any information for the current pull request with the commit f6871372fdc7d27e4b3ba1789fb13fdba44f961c. You might need to set the 'NX_BRANCH' environment variable in your CI pipeline.
Check the Nx Cloud Github Integration documentation for more information.
Sent with 💌 from NxCloud.
Hey @tamazlykar, what is the reasoning behind adding this operator? Property
's are designed so that value comparison is an implementation detail and I wouldn't want to expose any kinds of "comparators" to the end user. By design, values are always compared by reference, if you need deep comparison this usually means the structure is mutated. Any kinds of mutations and similar impurities are out of scope of frp-ts
Ok, I see you need deep comparison due to different object literals (different references) even their contents are the same. Well, I can't say such things are in the spirit of frp-ts as the intention is clearly to set the new reference and deep comparison looks like a "fix" for that. Instead I'd suggest moving the comparison out of the set
to a condition wrapping that set
.
const a = newAtom({ name: 'foo' })
a.set({ name: 'foo' }) // the intention is to push new object
if (!deepEqual(a.get(), {name: 'foo'})) { // the intention is to check deeply
a.set({ name: 'foo' })
}
ok found the original issue, linking https://github.com/raveclassic/frp-ts/issues/59