My Store class is designed to accept the state type as a generic parameter.
class Store<T> {
}
When extending the store, I typically do something like:
interface State {
entities: { [id: string] : Todo }
}
class Todos extends Store<State> {
}
Now, I want to include a method in my store that will return the entities.
class Store<T> {
private _store: BehaviorSubject<T>;
constructor(initialState) {
super();
this._store = new BehaviorSubject(initialState);
}
getEntities() {
return this._store.map(state => state.entities);
}
}
How can I specify the return type of getEntities
to be of the Todo type in this scenario?