-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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(localforage): add support for custom drivers #282
Conversation
Whoa! This is awesome and unexpected ^_^ 👍 I'll look through now, but I like the idea. |
Looking through the code, it looks like each instance of localForage has the |
Driver definitions are available for all instances to be used, since the |
Awesome. Okay cool. I think there are a few nitpicks but I'll clean them up and merge this in. Awesome stuff! |
var defineDriver = new Promise(function(resolve, reject) { | ||
try { | ||
var driverName = driverObject._driver; | ||
var complianceError = new Error('Custom driver not complian.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll fix this and a few whitespace things before merging, but it's "compliant" 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like, that besides naming I also have typo issues.
This should also be changed in src/localforage.js test.customdriver.js.
Totally awesome; thanks so much 👍 I'm drafting up a release of 1.1 to add this in now :-) |
Love this, thank you so much! |
Resolves #267
This is a simple implementation, not guessing the use of requirejs, browserify or anything else.
The developer uses an async call like
localforage.defineDriver(dummyStorageDriver);
and passes a "driver definition object" that should look likeIt also may contain a
_support
property that is either boolean (true/false) or it returns aPromise
that resolves to a boolean value. If_support
is omitted, thentrue
is used.For a brief how-to take a look at
test/dummyStorageDriver.js
andtest/test.customdriver.js
.PS: The async nature of the
defineDriver
method may also prove useful for a future implementation that utilizes requirejs/browserify to load the driver, as presented in this comment of #267.PS2: Also, my naming may be bad.