Proxying the Constructor
Explore how to create a function that proxies a constructor for local storage use in Marionette.js. Understand the process of replacing constructors and safely accessing references to enable data persistence in client-side applications.
We'll cover the following...
We'll cover the following...
With these basics in place, here’s what we want to have a function that will receive a reference to a constructor, e.g., the Contact constructor, and modify it for use with local storage.
Creating a new constructor
So, let’s create a configureStorage function that will do just that:
Our configureStorage function takes a constructor as an argument in line 1, assigns it to the OldConstructor variable for readability in line 2, and then defines a new constructor in lines 3–6. This ...