Code Monkey home page Code Monkey logo

ngx-localforage's People

Contributors

dependabot[bot] avatar radyz avatar xepe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ngx-localforage's Issues

Multiple Instances

How can this be implemented in the current library? Can you expose the methods to createInstance and dropInstance?

I got TypeError: this.localForage.setItem is not a function when run unit test

*****file *.spec.ts
import { TestBed, inject } from '@angular/core/testing';

import { LocalStorageService } from './local-storage.service';
import { LocalForageService, LocalForageToken } from 'ngx-localforage';

describe('LocalStorageService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
providers: [LocalStorageService, LocalForageService, LocalForageToken]
});
});

it('should be created', inject([LocalStorageService], (local: LocalStorageService) => {
    expect(local).toBeTruthy();
}));

it('should have properties and methods', inject([LocalStorageService], (local: LocalStorageService) => {
    expect(local.setAdminAuth).toBeDefined();
    expect(local.getAdminAuth).toBeDefined();
}));

describe('Service return correct result', () => {
    let expectedResult = { username: 'user1', password: 'test1234' };
    it('should pass the result as Promise', inject([LocalStorageService], (local: LocalStorageService) => {
        **local.setAdminAuth**('user1', 'test1234').then((result) => {
            expect(result).toEqual(expectedResult);
        })
    }));
});

});
##############################################################
import { Injectable } from '@angular/core';
import { LocalForageService } from 'ngx-localforage';

@Injectable()
export class LocalStorageService {

constructor(private local: LocalForageService) { }

setAdminAuth(username = '', password = '') {
    return this.local.setItem('admin-auth', { username: username, password: password }).toPromise();
}

getAdminAuth() {
    return this.local.getItem('admin-auth').toPromise();
}

}

######################################################
TypeError: this.localForage.setItem is not a function
at LocalForageService.webpackJsonp.../../../../ngx-localforage/dist/localforage.service.js.LocalForageService.setItem (http://localhost:9876/_karma_webpack_/webpack:/usr/local/www/tuifree-web/node_modules/ngx-localforage/dist/localforage.service.js:19:1)
at LocalStorageService.webpackJsonp.../../../../../src/app/local-storage.service.ts.LocalStorageService.setAdminAuth (http://localhost:9876/_karma_webpack_/webpack:/usr/local/www/tuifree-web/src/app/local-storage.service.ts:10:27)
at UserContext. (http://localhost:9876/_karma_webpack_/webpack:/usr/local/www/tuifree-web/src/app/local-storage.service.spec.ts:39:19)
at TestBed.webpackJsonp.../../../core/esm5/testing.js.TestBed.execute (http://localhost:9876/_karma_webpack_/webpack:/usr/local/www/tuifree-web/node_modules/@angular/core/esm5/testing.js:1013:1)
at UserContext. (http://localhost:9876/_karma_webpack_/webpack:/usr/local/www/tuifree-web/node_modules/@angular/core/esm5/testing.js:1143:29)
at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invoke (http://localhost:9876/_karma_webpack_/webpack:/usr/local/www/tuifree-web/node_modules/zone.js/dist/zone.js:392:1)
at ProxyZoneSpec.webpackJsonp.../../../../zone.js/dist/proxy.js.ProxyZoneSpec.onInvoke (http://localhost:9876/_karma_webpack_/webpack:/usr/local/www/tuifree-web/node_modules/zone.js/dist/proxy.js:79:1)
at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invoke (http://localhost:9876/_karma_webpack_/webpack:/usr/local/www/tuifree-web/node_modules/zone.js/dist/zone.js:391:1)
at Zone.webpackJsonp.../../../../zone.js/dist/zone.js.Zone.run (http://localhost:9876/_karma_webpack_/webpack:/usr/local/www/tuifree-web/node_modules/zone.js/dist/zone.js:142:1)
at UserContext. (http://localhost:9876/_karma_webpack_/webpack:/usr/local/www/tuifree-web/node_modules/zone.js/dist/jasmine-patch.js:104:1)

How to fix this case?

angular5
test with karma unit test.

This module is not AOT compliant

Hello,

Thank you for developing this module! I love localforage and I love angular2.

I was getting an error when trying to build my app using AOT:
Uncaught Error: Unexpected value 'undefined' imported by the module 'LocalForageModule'

I believe these are caused by the export * from in the barrel files. See here for why.

I've managed to fix this, will be pushing a pull request soon.

How Do I Connect This ?

`let localforage: LocalForage
const config: LocalForageConfiguration = {
driver: localforage.INDEXEDDB,
name: 'Cashier',
version: 1.0,
storeName: 'transact_1', // Should be alphanumeric, with underscores.
description: 'Transactions',
size: 100000000
};

this.localforage.config(config).subscribe(() => {
  console.log('Localforage configured :D');
}), (err => console.error('Error configuring localforage', err));

`
localforage indexeddb is returning null =_= any help?

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.