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

Update LocalForage dependency #140

Closed
wants to merge 1 commit into from
Closed

Update LocalForage dependency #140

wants to merge 1 commit into from

Conversation

salbahra
Copy link

This solves #133 by giving developers the ability to monkey patch the instance. Once this PR is approved the following code would allow IndexedDB to work on Safari 10.1+ when using Ionic.

import { Storage } from "@ionic/storage";

constructor( private storage: Storage ) {
        this.storage.ready().then( ( localForageInstance ) => {
            localForageInstance.getDriver( localForageInstance.INDEXEDDB ).then( ( driver ) => {
                if ( driver._support ) {
                    this.init();
                } else {
                    driver._support = true;
                    return localForageInstance.defineDriver( driver ).then( () => {
                        localForageInstance.setDriver( localForageInstance.INDEXEDDB ).then( this.init.bind( this ) );
                    } );
                }
            } );
}

private init() { console.log( "Loaded!" ); }

@vptcnt
Copy link

vptcnt commented Feb 11, 2018

Hello,
I have the same problem with safari.
Where should I add this code in an Ionic 3 project ? One in app.ts ? or before each call ?

Thanks for your help

@salbahra
Copy link
Author

@vptcnt I am using a shared provider to wrap Ionic storage so I am only doing this once.

@salbahra
Copy link
Author

After spending hours of my time I found #101 shows the exact same thing. Why is this taking so long to address when a compatibility layer is offered?

@mhartington mhartington closed this Jun 8, 2018
@salbahra salbahra deleted the update-localforage-dependency branch June 30, 2018 20:57
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.

3 participants