Closed jonathanhecl closed 6 years ago
@PillowPillow From what I saw, @jarbitlira PR works great. Could you please update the library?
yeah. I've just hit this roadblock
Hello, the latest version 3.0.0-beta.6 is compliant with Angular 7. This version's still in beta because of the lacking of documentation but is fully tested and functional. It's a full rewrite of the library allowing to easily add storage strategies support like indexedDB or simple stubs in unit tests.
The only breaking change should be the renaming of the main module - NgxWebstorageModule (instead of Ng2Webstorage).
Sorry for the inconvenience
Regards,
Hello!
BUILD ERROR [3] : Unexpected value 'Ng2Webstorage in '../node_modules/ngx-webstorage/ngx-webstorage.d.ts' imported by the module 'MyModule in 'xxxx'. Please add a @NgModule annotation.
How can I solve this error?
Regards
rm -rf node_modules rm -rf package-lock.json npm install
Is it working now ? Don't forget to rename Ng2Webstorage to NgxWebstorageModule if you are using the v3.x. Moreover the .forRoot()
is now mandatory in the root module, even if you don't need to configure the library (cf first section of the readme).
@PillowPillow it's not working yet. Appears this error:
Error: invalid_strategy at Function.push../node_modules/ngx-webstorage/fesm5/ngx-webstorage.js.StrategyIndex.get (ngx-webstorage.js:697) at ProjectViewerService.get (ngx-webstorage.js:902) at new ProjectViewerService (a2k-common.js:5401) at ProjectViewerService_Factory (a2k-common.js:5941) at _callFactory (core.js:17497) at createProviderInstance (core.js:17455) at resolveNgModuleDep (core.js:17430) at NgModuleRef.push../nodemodules/@angular/core/fesm5/core.js.NgModuleRef.get (core.js:18124) at inject (core.js:1023) at SessionService_Factory (a2k-common.js:6089)
@PillowPillow using strategy 'session_strategy' Error: invalid_strategy
Using this library in app.module:
NgxWebstorageModule.forRoot(),
and in another module called a2k.common
NgxWebstorageModule.forRoot(),
Something is wrong after upgrading angular 6.1.2 to angular 7 in ng2-webstorage...
Code is the same, nothing changed
Sorry for the inconvenience, but this is the only library that prevents me from updating the angular version
Can you remove the forRoot call in your second module ? This method must be called inside the root module only (like the angular's RouterModule.forRoot() ) I m using the beta7 in my company project and it works perfectly..
Edit
Tried with multi forRoot, it works too.. which version are you using currently ?
@PillowPillow Hello! I have found the solution to the problem. 1st - The secondary module was not being imported into the main module of the application (app.module.ts). 2nd - The secondary module must import ng2-webstorage without .forRoot() in its main module.
Sorry for the inconvenience
ok, glad to see that you found out a solution. Btw, you shouldn't have to import NgxWebstorageModule in your secondary module. The only purpose of importing multiple time a module in your application accross differents modules, is to give access to the exported components. The injectable providers are available in the whole application since you imported the library calling forRoot in your root module.
@PillowPillow I needed to import NgxWebstorageModule in secondary module because it has exported components that use @SessionStorage
I'm experiencing a similar issue and I have not been able to resolve it I'm using Angular 7. I'm using "ngx-webstorage": "^3.0.0-beta.8",
In my application app.module.ts I do the following NgxWebstorageModule.forRoot(), I'm getting the error listed below.
Any ideas how to resolve it?
Thank you
Error: invalid_strategy at Function.push../node_modules/ngx-webstorage/fesm5/ngx-webstorage.js.StrategyIndex.get (ngx-webstorage.js:856) at StrategyIndex.push../node_modules/ngx-webstorage/fesm5/ngx-webstorage.js.StrategyIndex.getStrategy (ngx-webstorage.js:920) at buildService$1 (ngx-webstorage.js:1016) at _callFactory (core.js:17499) at createProviderInstance (core.js:17455) at initNgModule (core.js:17385) at new NgModuleRef (core.js:18112) at createNgModuleRef (core.js:18101) at Object.debugCreateNgModuleRef [as createNgModuleRef] (core.js:19932) at NgModuleFactory_.push../nodemodules/@angular/core/fesm5/core.js.NgModuleFactory.create (core.js:20660)
The invalid_strategy means that the application's trying to access to a not registered strategy in the strategyIndex.. (The StrategyIndex.index
property should be filled with the Local, Session and InMemory strategies)
Since the strategy indexing occurs at the module instanciation, i don't know how it could be possible...
Can you provide me an ultra basic sample repo that i could use to debug ?
Currently i didn't found out a way to reproduce your issue in the sandbox or in my production projects.
Edit:
Ok, i think i found the issue. The positition in the imports array matter.. Please check that you're importing the NgxWebstorageModule BEFORE any modules that need the library. (aka using LocalStorageService, Session.. or a decorator).
I'll try to fix that in the next beta
The invalid_strategy means that the application's trying to access to a not registered strategy in the strategyIndex.. (The
StrategyIndex.index
property should be filled with the Local, Session and InMemory strategies) Since the strategy indexing occurs at the module instanciation, i don't know how it could be possible... Can you provide me an ultra basic sample repo that i could use to debug ?Currently i didn't found out a way to reproduce your issue in the sandbox or in my production projects.
Edit:
Ok, i think i found the issue. The positition in the imports array matter.. Please check that you're importing the NgxWebstorageModule BEFORE any modules that need the library. (aka using LocalStorageService, Session.. or a decorator).
I'll try to fix that in the next beta
Reverted to import { Ng2Webstorage } from '@rars/ngx-webstorage'; for now, spent too much time trying to figure out why it was failing. Once you have a fix I'll revert back to your module. Thank you for the work and help.
If i'm right the beta-9 should fix your issue, but since you didn't gave me more info i can't be sure. If you try it, let me know the result.
@PillowPillow Thank you for your help, unfortunately no luck.
I have a library that contains a module which imports the NgxWebstorageModule, on my main application in the app.module I import NgxWebstorageModule.forRoot().
I tried importing NgxWebstorageModule before the shared module.
Below is the error I'm getting. For now I will put my upgrade to Angular 7 on hold, I will create a test environment in parallel to test the upgrade. I'll keep you posted as I make progress.
Thank you
Navigated to http://localhost:4200/ main.ts:12 Error: StaticInjectorError(MainPortalModule)[RampDataService -> SessionStorageService]: StaticInjectorError(Platform: core)[RampDataService -> SessionStorageService]: NullInjectorError: No provider for SessionStorageService! at NullInjector.get (core.js:791) at resolveToken (core.js:1096) at tryResolveToken (core.js:1027) at StaticInjector.get (core.js:889) at resolveToken (core.js:1096) at tryResolveToken (core.js:1027) at StaticInjector.get (core.js:889) at resolveNgModuleDep (core.js:22044) at _createClass (core.js:22112) at _createProviderInstance (core.js:22077) client:148 [WDS] Warnings while compiling. warnings @ client:148 onmessage @ socket.js:41 EventTarget.dispatchEvent @ sockjs.js:170 (anonymous) @ sockjs.js:887 SockJS._transportMessage @ sockjs.js:885 EventEmitter.emit @ sockjs.js:86 WebSocketTransport.ws.onmessage @ sockjs.js:2961 wrapFn @ zone.js:1188 push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask @ zone.js:421 push../node_modules/zone.js/dist/zone.js.Zone.runTask @ zone.js:188 push../node_modules/zone.js/dist/zone.js.ZoneTask.invokeTask @ zone.js:496 invokeTask @ zone.js:1540 globalZoneAwareCallback @ zone.js:1566 client:154 ./node_modules/@ramp/ramp-angular-library/node_modules/@angular/core/fesm2015/core.js 18196:15-36 Critical dependency: the request of a dependency is an expression warnings @ client:154 onmessage @ socket.js:41 EventTarget.dispatchEvent @ sockjs.js:170 (anonymous) @ sockjs.js:887 SockJS._transportMessage @ sockjs.js:885 EventEmitter.emit @ sockjs.js:86 WebSocketTransport.ws.onmessage @ sockjs.js:2961 wrapFn @ zone.js:1188 push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask @ zone.js:421 push../node_modules/zone.js/dist/zone.js.Zone.runTask @ zone.js:188 push../node_modules/zone.js/dist/zone.js.ZoneTask.invokeTask @ zone.js:496 invokeTask @ zone.js:1540 globalZoneAwareCallback @ zone.js:1566 client:154 ./node_modules/@ramp/ramp-angular-library/node_modules/@angular/core/fesm2015/core.js 18213:15-102 Critical dependency: the request of a dependency is an expression warnings @ client:154 onmessage @ socket.js:41 EventTarget.dispatchEvent @ sockjs.js:170 (anonymous) @ sockjs.js:887 SockJS._transportMessage @ sockjs.js:885 EventEmitter.emit @ sockjs.js:86 WebSocketTransport.ws.onmessage @ sockjs.js:2961 wrapFn @ zone.js:1188 push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask @ zone.js:421 push../node_modules/zone.js/dist/zone.js.Zone.runTask @ zone.js:188 push../node_modules/zone.js/dist/zone.js.ZoneTask.invokeTask @ zone.js:496 invokeTask @ zone.js:1540 globalZoneAwareCallback @ zone.js:1566
Here is my Injectable - nothing sophisticated
' import { Injectable } from '@angular/core'; import * as collections from 'typescript-collections'; import { SessionStorageService, SessionStorage } from 'ngx-webstorage';
@Injectable() export class RampDataService {
// ---------------------------------------------------------------------------------------------------------
public constructor(private _sessionStorage: SessionStorageService) {
}
// ---------------------------------------------------------------------------------------------------------
public Push(key: string, value: any): any {
this._sessionStorage.store(key, value);
return value;
}
// ---------------------------------------------------------------------------------------------------------
public Pop(key: string): any {
const value = this._sessionStorage.retrieve(key);
this._sessionStorage.clear(key);
return value;
}
// ---------------------------------------------------------------------------------------------------------
public Get(key: string): any {
return this._sessionStorage.retrieve(key);
}
// ---------------------------------------------------------------------------------------------------------
public Remove(key: string): any {
const value = this._sessionStorage.retrieve(key);
this._sessionStorage.clear(key);
return value;
}
// ---------------------------------------------------------------------------------------------------------
public isEmpty(key: string): any {
const obj = this._sessionStorage.retrieve(key);
return (null == obj || Object.keys(obj).length === 0);
}
// ---------------------------------------------------------------------------------------------------------
public Clear() {
this._sessionStorage.clear();
}
// --------------------------------------------------------------------------------------------------------- } '
Ok, so you have 2 separated applications (a lib and an app)? Try to add the forRoot call in your library main module too, in your case i think it should works. The forRoot declares every providers of the library, as far as i can see, your library try to access to the service before the provider's declarations.
I tried that as well, but I got another error, unfortunately I did not capture it. I'll try to get my test environment back up again and give it another try.
@PillowPillow I was able to get a test sandbox up. I tried .forRoot() with every combination possible, in the library and/or application. I still get the same error.
I've changed the library not to use the .forRoot() and only use .forRoot() in the application. I made sure that the import is before the library in the application, just in case.
Here's the error that I'm getting, since I have an area to play with, let me know if you want me to try something. Anything to help.
Thank you
[WDS] App updated. Reloading... Navigated to http://localhost:4200/ main.ts:12 Error: invalid_strategy at Function.push../node_modules/ngx-webstorage/fesm5/ngx-webstorage.js.StrategyIndex.get (ngx-webstorage.js:856) at StrategyIndex.push../node_modules/ngx-webstorage/fesm5/ngx-webstorage.js.StrategyIndex.getStrategy (ngx-webstorage.js:920) at buildService$1 (ngx-webstorage.js:1015) at _callFactory (core.js:17851) at createProviderInstance (core.js:17807) at initNgModule (core.js:17737) at new NgModuleRef (core.js:18464) at createNgModuleRef (core.js:18453) at Object.debugCreateNgModuleRef [as createNgModuleRef] (core.js:20284) at NgModuleFactory_.push../nodemodules/@angular/core/fesm5/core.js.NgModuleFactory.create (core.js:21012)
it's weird.. Are you sure that you're using the latest beta (3.0.0-beta.9) ? Can you provide me an access to test that myself with your environment ?
it's weird.. Are you sure that you're using the latest beta (3.0.0-beta.9) ? Can you provide me an access to test that myself with your environment ?
@PillowPillow I will try to strip down my test environment. However, I believe that the issue might be that I have a call to the APP_INITIALIZER which loads my configs which depends on SessionStorageService.
I notice that you also call APP_INITIALIZER in your module. I tried to do this
{ provide: APP_INITIALIZER, useFactory: configServiceFactory, deps: [StrategyIndex, SessionStorageService, RampConfigService], multi: true }
export function configServiceFactory(index: StrategyIndex, xx: SessionStorageService, configService: RampConfigService) {
return () => {
index.indexStrategies();
return configService.load();
};
}
Now I'm getting this error - I hope this helps you
Navigated to http://localhost:4200/ ngx-webstorage.js:856 session_strategy undefined core.js:12632 ERROR TypeError: Cannot read property 'get' of null at SyncStorage.push../node_modules/ngx-webstorage/fesm5/ngx-webstorage.js.SyncStorage.retrieve (ngx-webstorage.js:142) at RampDataService.push../node_modules/@ramp/ramp-angular-library/fesm5/ramp-ramp-angular-library.js.RampDataService.isEmpty (ramp-ramp-angular-library.js:145) at RampConfigService.push../node_modules/@ramp/ramp-angular-library/fesm5/ramp-ramp-angular-library.js.RampConfigService.setConfig (ramp-ramp-angular-library.js:1025) at SafeSubscriber._next (ramp-ramp-angular-library.js:965) at SafeSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.SafeSubscriber.tryOrUnsub (Subscriber.js:196) at SafeSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.SafeSubscriber.next (Subscriber.js:134) at Subscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._next (Subscriber.js:77) at Subscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (Subscriber.js:54) at MapSubscriber.push../node_modules/rxjs/_esm5/internal/operators/map.js.MapSubscriber._next (map.js:41) at MapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (Subscriber.js:54) defaultErrorLogger @ core.js:12632 push../node_modules/@angular/core/fesm5/core.js.ErrorHandler.handleError @ core.js:12680 push../src/app/app-error-handler.ts.AppErrorHandler.handleError @ app-error-handler.ts:42 next @ core.js:14659 schedulerFn @ core.js:10206 push../node_modules/rxjs/_esm5/internal/Subscriber.js.SafeSubscriber.tryOrUnsub @ Subscriber.js:196 push../node_modules/rxjs/_esm5/internal/Subscriber.js.SafeSubscriber.next @ Subscriber.js:134 push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._next @ Subscriber.js:77 push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next @ Subscriber.js:54 push../node_modules/rxjs/_esm5/internal/Subject.js.Subject.next @ Subject.js:47 push../node_modules/@angular/core/fesm5/core.js.EventEmitter.emit @ core.js:10190 (anonymous) @ core.js:14213 push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke @ zone.js:388 push../node_modules/zone.js/dist/zone.js.Zone.run @ zone.js:138 push../node_modules/@angular/core/fesm5/core.js.NgZone.runOutsideAngular @ core.js:14150 onHandleError @ core.js:14213 push../node_modules/zone.js/dist/zone.js.ZoneDelegate.handleError @ zone.js:392 push../node_modules/zone.js/dist/zone.js.Zone.runTask @ zone.js:191 push../node_modules/zone.js/dist/zone.js.ZoneTask.invokeTask @ zone.js:496 ZoneTask.invoke @ zone.js:485 timer @ zone.js:2054 setTimeout (async) scheduleTask @ zone.js:2075 push../node_modules/zone.js/dist/zone.js.ZoneDelegate.scheduleTask @ zone.js:407 onScheduleTask @ zone.js:297 push../node_modules/zone.js/dist/zone.js.ZoneDelegate.scheduleTask @ zone.js:401 push../node_modules/zone.js/dist/zone.js.Zone.scheduleTask @ zone.js:232 push../node_modules/zone.js/dist/zone.js.Zone.scheduleMacroTask @ zone.js:255 scheduleMacroTaskWithCurrentZone @ zone.js:1114 (anonymous) @ zone.js:2090 proto.(anonymous function) @ zone.js:1394 hostReportError @ hostReportError.js:3 push../node_modules/rxjs/_esm5/internal/Subscriber.js.SafeSubscriber.tryOrUnsub @ Subscriber.js:204 push../node_modules/rxjs/_esm5/internal/Subscriber.js.SafeSubscriber.next @ Subscriber.js:134 push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._next @ Subscriber.js:77 push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next @ Subscriber.js:54 push../node_modules/rxjs/_esm5/internal/operators/map.js.MapSubscriber._next @ map.js:41 push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next @ Subscriber.js:54 push../node_modules/rxjs/_esm5/internal/operators/filter.js.FilterSubscriber._next @ filter.js:38 push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next @ Subscriber.js:54 push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapSubscriber.notifyNext @ mergeMap.js:84 push../node_modules/rxjs/_esm5/internal/InnerSubscriber.js.InnerSubscriber._next @ InnerSubscriber.js:15 push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next @ Subscriber.js:54 push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._next @ Subscriber.js:77 push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next @ Subscriber.js:54 onLoad @ http.js:1534 push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask @ zone.js:421 onInvokeTask @ core.js:14182 push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask @ zone.js:420 push../node_modules/zone.js/dist/zone.js.Zone.runTask @ zone.js:188 push../node_modules/zone.js/dist/zone.js.ZoneTask.invokeTask @ zone.js:496 invokeTask @ zone.js:1540 globalZoneAwareCallback @ zone.js:1566 error (async) customScheduleGlobal @ zone.js:1666 push../node_modules/zone.js/dist/zone.js.ZoneDelegate.scheduleTask @ zone.js:407 onScheduleTask @ zone.js:297 push../node_modules/zone.js/dist/zone.js.ZoneDelegate.scheduleTask @ zone.js:401 push../node_modules/zone.js/dist/zone.js.Zone.scheduleTask @ zone.js:232 push../node_modules/zone.js/dist/zone.js.Zone.scheduleEventTask @ zone.js:258 (anonymous) @ zone.js:1831 (anonymous) @ http.js:1619 push../node_modules/rxjs/_esm5/internal/Observable.js.Observable._trySubscribe @ Observable.js:43 push../node_modules/rxjs/_esm5/internal/Observable.js.Observable.subscribe @ Observable.js:29 push../node_modules/rxjs/_esm5/internal/operators/catchError.js.CatchOperator.call @ catchError.js:18 push../node_modules/rxjs/_esm5/internal/Observable.js.Observable.subscribe @ Observable.js:24 (anonymous) @ subscribeTo.js:21 subscribeToResult @ subscribeToResult.js:11 push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapSubscriber._innerSub @ mergeMap.js:74 push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapSubscriber._tryNext @ mergeMap.js:68 push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapSubscriber._next @ mergeMap.js:51 push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next @ Subscriber.js:54 (anonymous) @ scalar.js:5 push../node_modules/rxjs/_esm5/internal/Observable.js.Observable._trySubscribe @ Observable.js:43 push../node_modules/rxjs/_esm5/internal/Observable.js.Observable.subscribe @ Observable.js:29 push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapOperator.call @ mergeMap.js:29 push../node_modules/rxjs/_esm5/internal/Observable.js.Observable.subscribe @ Observable.js:24 push../node_modules/rxjs/_esm5/internal/operators/filter.js.FilterOperator.call @ filter.js:15 push../node_modules/rxjs/_esm5/internal/Observable.js.Observable.subscribe @ Observable.js:24 push../node_modules/rxjs/_esm5/internal/operators/map.js.MapOperator.call @ map.js:18 push../node_modules/rxjs/_esm5/internal/Observable.js.Observable.subscribe @ Observable.js:24 (anonymous) @ ramp-ramp-angular-library.js:964 ZoneAwarePromise @ zone.js:891 push../node_modules/@ramp/ramp-angular-library/fesm5/ramp-ramp-angular-library.js.RampConfigService.load @ ramp-ramp-angular-library.js:962 (anonymous) @ app.module.ts:57 push../node_modules/@angular/core/fesm5/core.js.ApplicationInitStatus.runInitializers @ core.js:13647 (anonymous) @ core.js:14662 _callAndReportToErrorHandler @ core.js:14755 (anonymous) @ core.js:14660 push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke @ zone.js:388 onInvoke @ core.js:14191 push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke @ zone.js:387 push../node_modules/zone.js/dist/zone.js.Zone.run @ zone.js:138 push../node_modules/@angular/core/fesm5/core.js.NgZone.run @ core.js:14105 push../node_modules/@angular/core/fesm5/core.js.PlatformRef.bootstrapModuleFactory @ core.js:14651 (anonymous) @ core.js:14691 push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke @ zone.js:388 push../node_modules/zone.js/dist/zone.js.Zone.run @ zone.js:138 (anonymous) @ zone.js:872 push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask @ zone.js:421 push../node_modules/zone.js/dist/zone.js.Zone.runTask @ zone.js:188 drainMicroTaskQueue @ zone.js:595 Promise.then (async) scheduleMicroTask @ zone.js:578 push../node_modules/zone.js/dist/zone.js.ZoneDelegate.scheduleTask @ zone.js:410 push../node_modules/zone.js/dist/zone.js.Zone.scheduleTask @ zone.js:232 push../node_modules/zone.js/dist/zone.js.Zone.scheduleMicroTask @ zone.js:252 scheduleResolveOrReject @ zone.js:862 ZoneAwarePromise.then @ zone.js:962 push../node_modules/@angular/core/fesm5/core.js.PlatformRef.bootstrapModule @ core.js:14691 ./src/main.ts @ main.ts:11 __webpack_require @ bootstrap:83 0 @ main.ts:12 __webpack_require @ bootstrap:83 checkDeferredModules @ bootstrap:45 webpackJsonpCallback @ bootstrap:32 (anonymous) @ main.js:1 app-error-handler.ts:39 TypeError: Cannot read property 'get' of null at SyncStorage.push../node_modules/ngx-webstorage/fesm5/ngx-webstorage.js.SyncStorage.retrieve (ngx-webstorage.js:142) at RampDataService.push../node_modules/@ramp/ramp-angular-library/fesm5/ramp-ramp-angular-library.js.RampDataService.isEmpty (ramp-ramp-angular-library.js:145) at RampConfigService.push../node_modules/@ramp/ramp-angular-library/fesm5/ramp-ramp-angular-library.js.RampConfigService.setConfig (ramp-ramp-angular-library.js:1025) at SafeSubscriber._next (ramp-ramp-angular-library.js:965) at SafeSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.SafeSubscriber.tryOrUnsub (Subscriber.js:196) at SafeSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.SafeSubscriber.next (Subscriber.js:134) at Subscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._next (Subscriber.js:77) at Subscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (Subscriber.js:54) at MapSubscriber.push../node_modules/rxjs/_esm5/internal/operators/map.js.MapSubscriber._next (map.js:41) at MapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (Subscriber.js:54)
Hi @kambbado , thanks for your feedback. A new release 3.0.0-beta.10 is available and should handle your case.
Regards,
Hi @kambbado , thanks for your feedback. A new release 3.0.0-beta.10 is available and should handle your case.
Regards,
Success... I was able to get everything working. Thank you for your help.
@PillowPillow, in the retrieve
method in syncStorage.ts
, you return null
for falsy values:
https://github.com/PillowPillow/ng2-webstorage/blob/master/projects/ngx-webstorage/src/lib/core/templates/syncStorage.ts#L14
That makes it impossible to assign a value of false
to a key.
If that was intended, it should be in the docs, I think - it took me a while to track it down after upgrading to 3.0.0-beta.10
Hi @MasterRennor, thanks for your feedback, it was an error. A new version, 3.0.0-beta.11 is available and should fix it.
@PillowPillow, thanks for the instant fix! Working great with falsy values now.
@PillowPillow, is this also compatible with angular 8, getting below errors,
ERROR in node_modules/ngx-webstorage/lib/strategies/baseSyncStorage.d.ts:12:9 - error TS1086: An accessor cannot be declared in an ambient context.
12 get isAvailable(): boolean;
Hello, Which version are you using ? For angular 8 you should use the v4.x of the library
Hi @PillowPillow I am encountering an issue while trying to use 'NgxWebstorageModule' in Angular 9 project. I have a feature library wherein I am accessing local storage stuff. When I am importing the module in main module, I am getting this error:
core.js:4127 ERROR NullInjectorError: R3InjectorError(AppModule)[LocalStorageService -> LocalStorageService -> LocalStorageService -> LocalStorageService]: NullInjectorError: No provider for LocalStorageService! at NullInjector.push.../../node_modules/@angular/core/ivy_ngcc__/fesm5/core.js.NullInjector.get (http://localhost:4200/vendor.js:33938:25) at R3Injector.push.../../node_modules/@angular/core/ivy_ngcc/fesm5/core.js.R3Injector.get (http://localhost:4200/vendor.js:44576:33) at R3Injector.push.../../node_modules/@angular/core/__ivy_ngcc/fesm5/core.js.R3Injector.get (http://localhost:4200/vendor.js:44576:33) at R3Injector.push.../../node_modules/@angular/core/ivy_ngcc__/fesm5/core.js.R3Injector.get (http://localhost:4200/vendor.js:44576:33) at NgModuleRef$1.push.../../node_modules/@angular/core/ivy_ngcc/fesm5/core.js.NgModuleRef$1.get (http://localhost:4200/vendor.js:57838:33) at R3Injector.push.../../node_modules/@angular/core/__ivy_ngcc/fesm5/core.js.R3Injector.get (http://localhost:4200/vendor.js:44576:33) at NgModuleRef$1.push.../../node_modules/@angular/core/__ivy_ngcc__/fesm5/core.js.NgModuleRef$1.get (http://localhost:4200/vendor.js:57838:33) at Object.get (http://localhost:4200/vendor.js:56074:35) at getOrCreateInjectable (http://localhost:4200/vendor.js:36849:39) at Module.ɵɵdirectiveInject (http://localhost:4200/vendor.js:47380:12)
I tried adding NgxWebstorageModule without forRoot() in the feature lib,still it doesnt work. I even imported NgxWebstorageModule.forRoot() in feature lib as well along with the main module,it still keeps throwing the same error. Could you please assist here?
Thanks.