Created
May 9, 2018 03:20
-
-
Save taylorc/95fdcae69590ad89481f038a1a971b0e to your computer and use it in GitHub Desktop.
view-posts.component.ts
This file contains hidden or 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
import { Observable } from 'rxjs/Observable'; | |
import { Component, OnInit } from '@angular/core'; | |
import { ActivatedRoute } from '@angular/router'; | |
import { Select, Store } from '@ngxs/store'; | |
import { FetchPosts } from '../../shared/posts/post.actions'; | |
import { PostState } from '../../shared/posts/post.store'; | |
@Component({ | |
selector: 'app-view-posts', | |
templateUrl: './view-posts.component.html', | |
styleUrls: ['./view-posts.component.css'] | |
}) | |
export class ViewPostsComponent implements OnInit { | |
constructor(private store: Store, private route: ActivatedRoute) { } | |
@Select(PostState.loading) loading$: Observable<boolean>; | |
@Select(PostState.posts) posts$: Observable<Post[]>; | |
ngOnInit() { | |
this.store.dispatch(new FetchPosts()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment