Skip to content

Commit

Permalink
Fix load empty data
Browse files Browse the repository at this point in the history
  • Loading branch information
bodhivb committed Jun 6, 2023
1 parent 37606cc commit 02cf6f6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
12 changes: 12 additions & 0 deletions source/store/teacherStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ class TeacherStore extends DataStore<ITeacher[]> {
constructor() {
super("teachers");
}

/** Get teachers data */
public GetData(): ITeacher[] {
const data = super.GetData();

// Check if data is valid
if (data.length) {
return data;
} else {
return [];
}
}
}

export const teacherStore = new TeacherStore();
4 changes: 2 additions & 2 deletions source/views/schoolView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ export class SchoolView extends View {
this.teachers = [];

// Load new teachers
const teachers = teacherStore.GetData();
for (let teacher of teachers) {
const data = teacherStore.GetData();
for (let teacher of data) {
let sprite = new Teacher(teacher);
//sprite.pivot = new Point(-200, -800);
this.addChild(sprite);
Expand Down

0 comments on commit 02cf6f6

Please sign in to comment.