-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Description
I was thinking on this some more: omniscientjs/omniscient#104 (comment)
Rather than doing this naive check in shouldComponentUpdate, this may be done during development as an indicator that it should never occur. This can warn users that they're not really using the immutable library effectively.
API sketch:
// enable debug mode
if ('production' !== process.env.NODE_ENV) {
immstruct.debug();
}
const struct = immstruct({foo: [1, 2]});
// adding a listener through .on(), .observe(), etc enables value propagation check.
//
// internally, do something like this when values are propagated to listeners:
//
// if('production' !== process.env.NODE_ENV &&
// newRoot.getIn(path) !== oldRoot.getIn(path) &&
// Immutable.is(newRoot.getIn(path), oldRoot.getIn(path))) {
//
// console.warn('detected node with distinct reference but have same value');
// }
struct.on('swap', _ => _);
// deliberate bad practice
struct.cursor('foo').update(function() {
return Immutable.List.of(1, 2);
});Metadata
Metadata
Assignees
Labels
No labels