Open soniyaBisht04 opened 6 years ago
I've noticed that using setIdleName results in the appropriate creation of the new storage keys, but still created the default idling key
Not sure if that could potentially be causing issues for you
@soniyaBisht04 the way I figured to fix this it's to define a provider on each component that is going to declare its own ng2Idle instance. e.g
import { Idle, IdleExpiry, LocalStorageExpiry } from '@ng-idle/core';
@Component({
providers: [LocalStorageExpiry, { provide: IdleExpiry, useExisting: LocalStorageExpiry }, Idle],
selector: 'component-a',
template: ''
})
export class ComponentA {
constructor(public idle: Idle) {
this.idle.setIdleName('idleA');
}
}
import { Idle, IdleExpiry, LocalStorageExpiry } from '@ng-idle/core';
@Component({
providers: [LocalStorageExpiry, { provide: IdleExpiry, useExisting: LocalStorageExpiry }, Idle],
selector: 'component-b',
template: ''
})
export class ComponentB {
constructor(public idle: Idle) {
this.idle.setIdleName('idleB');
}
}
I hope this helps
I'm still see the ng2Idle.main.idling
being created
@jjlorenzo yeah, can't tell right now how to avoid that. What I'm doing is re-using the main idle for whatever I need, and then create another instance for something else
makes sense! thanks for confirming that
I want to create multiple instances of idle in the project. I tried using setIdleName each and every time am creating new instance, still timeout of one idle instance is triggering another timeout subscriber.
How we can actually make use of setIdleName or check which idle instance we are working on?