localForage / localForage-setItems

Adds setItems method to localForage.
Other
19 stars 5 forks source link

Can't get it to work #9

Closed geoidesic closed 4 years ago

geoidesic commented 4 years ago

I'm using ES6 imports on a VueJs SFC SPA. I tried the Typescript syntax but couldn't get it to work at all. It doesn't throw errors but the setItems method isn't added. (I get the same problem with getItems btw)

Error:

[Vue warn]: Error in mounted hook: "TypeError: src_boot_lf__WEBPACK_IMPORTED_MODULE_6__.lf.setItems is not a function"

Also I think the Typescript example has a case typo in it; should be localforage not localForage when importing.

geoidesic commented 4 years ago

Here's how to do it in ES6 with web pack. This will instal both setItems and getItems:

import localforage from "localforage";
import "localforage-getitems";
import "localforage-setitems";
import { extendPrototype as extendPrototypeSet } from "localforage-setitems";
import { extendPrototype as extendPrototypeGet } from "localforage-getitems";
extendPrototypeSet(localforage);
extendPrototypeGet(localforage);