@karvanj wrote:
Hi all, in my mission to embrace observables and extension from this post, I am writing to see how everyone would go about implementing a loading controller on fetch.
As a working example say I have an API fetch users in a service.
export class UserService { constructor( public http: Http ) {} public fetchUsers() { return this.http.get("/api/users").map((res: Response) => res.json()) } }
In my component page I have an observable that fetches new users on init.
export class UserList { public users$: Observable<Users[]> constructor( public userService: UserService, ) public ngOnInit() { this.users$ = this.userService.fetchUsers() } }
The question I am asking how would you implement a loading controller(ie a spinner wheel saying it’s loading) to start when fetching users begins. And then dismissed once completed. Is it possible using the observable method?
Posts: 1
Participants: 1