Hidden listing
function KlipseLoadLib(url, symbol) { if (window[symbol]) { return; } var script = document.createElement('script'); script.src = url; document.body.append(script); } KlipseLoadLib("https://cdnjs.cloudflare.com/ajax/libs/immutable/4.0.0/immutable.min.js", "Immutable"); class UserManagement {}; window.UserManagement = UserManagement;
In part 1, we illustrated how to manage the state of a system without mutating data, where immutability is maintained by constraining ourselves to manipulate the state only with immutable functions using structural sharing. In this chapter, we present a safer and more scalable way to preserve data immutability—representing data with so-called persistent data structures. Efficient implementations of persistent data structures exist for most programming languages via third-party libraries.