You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 modeif('production'!==process.env.NODE_ENV){immstruct.debug();}conststruct=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 practicestruct.cursor('foo').update(function(){returnImmutable.List.of(1,2);});
The text was updated successfully, but these errors were encountered:
// deliberate bad practicestruct.cursor('foo').update(function(){returnImmutable.List.of(1,2);});
is during bootstrap when you're loading your models before React.render(...) and before listeners are registered:
// enable debug modeif('production'!==process.env.NODE_ENV){immstruct.debug();}conststruct=immstruct({foo: [1,2]});// load model from database, xhr, etc. // this is done before any listeners are subscribed.struct.cursor('foo').update(function(){returnImmutable.List.of(1,2);});functionrender(){React.render(<Componentcursor={struct.cursor()})/>);// value propagation check is enabled after the first renderstruct.on('swap',render);}render();// deliberate bad practicestruct.cursor('foo').update(function(){returnImmutable.List.of(1,2);});
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:
The text was updated successfully, but these errors were encountered: