Giter Site home page Giter Site logo

DRIVER error about ngforage HOT 7 CLOSED

alorel avatar alorel commented on August 16, 2024
DRIVER error

from ngforage.

Comments (7)

Alorel avatar Alorel commented on August 16, 2024

Driver is only exported in ngforage^4.0.0. Refer to the old API for ngforage^3.0.0.

And it will not save to more than one store. See https://localforage.github.io/localForage/#settings-api-setdriver

If you're using the UMD bundle, you should upgrade to ngforage 4.x as soon as possible - there is a number of bugs in 3.x that have been resolved in 4.x.

from ngforage.

GlauberF avatar GlauberF commented on August 16, 2024

@Alorel
updated to ngforage^4.0.0

captura de tela de 2018-10-19 11-00-44

from ngforage.

Alorel avatar Alorel commented on August 16, 2024

Hm, what version of Typescript are you using?

from ngforage.

Alorel avatar Alorel commented on August 16, 2024

Additionally, please create a reproducible example as shown in the bug report issue template

from ngforage.

GlauberF avatar GlauberF commented on August 16, 2024

@Alorel

I updated the Angular to 7, typescript too and now it is working.
I have only one doubt:

in my module I'm inserting like this:

driver: [
                Driver.INDEXED_DB,
                Driver.LOCAL_STORAGE
]

like that in my call to write or save in the specific component which driver to use, example call.

public setItem (data) {
        console.log ('Setting value ...');
        try {
            this.ngf.setItem ('email', data.email)
                .then ((d) => {
                    console.log ('Value set!');
                    console.log (d);
                })
        } catch (e) {
            console.log (e);
        }
    }

example in this insert I want to send to localstorage

from ngforage.

Alorel avatar Alorel commented on August 16, 2024

If you want some component to bypass the default priority, you're best off injecting a DedicatedInstanceFactory:

@Component()
export class FooComponent {
  private readonly ngf: NgForage;

  public constructor(inst: DedicatedInstanceFactory,
                     private readonly standardNgf: NgForage) {
    this.ngf = inst.createNgForage({driver: [Driver.LOCAL_STORAGE]});
  }

  public async setItem(data: any) {
    console.log(`Set to IndexedDB OR localStorage: ${await this.standardNgf.setItem('foo', data)}`);
    console.log(`Set explicitly to localStorage: ${await this.ngf.setItem('bar', data)}`);
  }
}

from ngforage.

GlauberF avatar GlauberF commented on August 16, 2024

thanks :)

from ngforage.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.