Last active
May 17, 2020 18:52
-
-
Save splincode/de2d3ed54c86701db489ce287fb56532 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@StateRepository() | |
@State({ | |
name: 'courses', | |
defaults: createEntityCollections() | |
}) | |
@Injectable() | |
export class CoursesEntitiesState extends NgxsDataEntityCollectionsRepository<Course> {} | |
@StateRepository() | |
@State({ | |
name: 'lessons', | |
defaults: createEntityCollections() | |
}) | |
@Injectable() | |
export class LessonEntitiesState extends NgxsDataEntityCollectionsRepository<Lesson> {} | |
@Component({ | |
selector: 'app' | |
// .. | |
}) | |
export class AppComponent implements OnInit { | |
constructor(private courses: CoursesEntitiesState, private api: ApiCoursesService) {} | |
public ngOnInit(): void { | |
this.api.getCourses().subscribe((courses: Course[]) => { | |
this.courses.setAll(courses); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment