Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: show how to use mnemonic and storage #7

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

coolaj86
Copy link
Contributor

@coolaj86 coolaj86 commented Jul 3, 2022

A better example of how to use storage and mnemonic that puts storage and mnemonic code in ./lib/ as to make the example completely useful, but still simple at-a-glance.

Would replace #4

@coolaj86
Copy link
Contributor Author

coolaj86 commented Jul 3, 2022

Also, package.json.browser can be used to provide code samples for both Node.js and Browsers. For example:

{
  // ...
  "browser": {
    "./lib/storage.js": "./lib/browser-storage.js"
  },
  // ...
}

This would use ./lib/storage.js for Node.js, but ./lib/browser-storage.js in a browser (via bundlers). Then you can provide complete, usable examples that Just Work™ no matter the environment.

@markin-io
Copy link

The storage is currently under refactoring and the way we do it might become obsolete.
We'll revisit this piece of the documentation later once the change is done.

@coolaj86
Copy link
Contributor Author

Better maybe obsolete and working now than not working now and possibly just fine. In the browser you're stuck with a key/value store (localForage to get beyond the 10mb localStorage limit)... unless you get really crazy.

Might as well make the API something that either works relatively well with a key/value store, or that easily wraps a key/value store.

If the former, nothing breaks.

If the later, things are fixed with a one line change: newStorage = dapi.wrapKeyValue(oldStorage).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants