To attach the local-storage.js
to an Elm application, the code example in index.js
is used.
Note that there are 2 ways given in the example, one is using local code and the other is using the npm package.
The javascript implementation can be as shown in local-storge.js
.
The ports needed on the Elm side must be provided by your application. An example implementation can be seen in LocalStoragePort.elm
.
Lastly, in order to get back messages telling you when something has been found or not in local storage, or to get listings of available keys, you need to susbscribe to the ResponsePort
. The code snippet in Main.elm
shows how to set this up and what Response
s you can get and need to deal with in your update function.
In line #7, I think the "some.prefix" should be model.localStorageConfig; the LocalStorage config object should be passed