interface HeroesComponentState {
const initHeroesComponentState: Partial<HeroesComponentState> = {
templateUrl: './heroes.component.html',
styleUrls: ['./heroes.component.css'],
providers: [RxState] // <--- This binds RxState to the lifetime of the component
export class HeroesComponent {
@Select(getHeroes) stateHeroes$: Observable<Hero[]>; // <--- normal @Select use from NGXS
readonly heroes$: Observable<Hero[]> = this.state.select('heroes');
private state: RxState<HeroesComponentState>,
this.state.set(initHeroesComponentState);
this.state.connect('heroes', this.stateHeroes$); // <--- Here we connect NGXS with RxAngular