Replies: 1 comment
-
I don't think you understand how RxJS and Akita works. export interface ClassRoom {
id: number;
name: string;
studentIds: number[];
}
export interface ClassRoomState extends EntityState<ClassRoom>, ActiveState {}
@Injectable({
providedIn: 'root'
})
export class ClassRoomQuery extends QueryEntity<ClassRoomState> {
activeClassRoom$ = this.selectActive();
students$ = activeClassRoom$
.pipe(
switchMap(
classRoom => this.studentQuery.selectMany(classRoom.studentIds)
)
);
constructor(
protected readonly store: ClassRoomStore,
private readonly studentQuery: StudentQuery
) {
super(store);
}
} You need to learn how RxJS/Observables work before you can use Akita effectively. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm submitting a...
Current behavior
I try to nest a store in another store, so I need to query the nested store as well. Here is my demo code :
The
Students
is the nest store, it's used as a field inClassRoom
store. I need to query its data fromClassRoom
store, so I write thegetStudents
method inClassRoomQuery
.I'm not sure the way I write this method is correct. When I call it, it gave me an error:
How can I do it right?
Expected behavior
Query the nest store's data successfully.
Minimal reproduction of the problem with instructions
See the demo code above.
What is the motivation / use case for changing the behavior?
Nest store is only for entity collection. There are some other properties not suit there .
Environment
Beta Was this translation helpful? Give feedback.
All reactions