Is there any good way to force creating new instance of Angular2's injected Service? Let's say I have SomeService where I set a lot of fields on its creation:
@Injectable()
export class SomeService {
private initialized: boolean = false;
private things: Object[] = [];
private somethingElse: number = 0;
constructor(protected injectedService: InjectedService) {
this.initialized = true;
this.somethingElse = Math.floor(Math.random()*10);
this.injectedService.getThings(this.somethingElse)
.subscribe(things => this.things = things);
}
}
And then i.e. the user logs out and the all data set is no longer valid nor should be present there. Does Angular2 with Typescript provide any way to destruct current service instance and get new one or do I have to fetch the logout event and clean up all the data manually?