17.10.2018 Views

Angular

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

placeholder="Username"<br />

[disabled]="(user | async).isConnecting"<br />

ngModel<br />

Log me in<br />

<br />

Log me out<br />

`<br />

})<br />

export class LoginComponent {<br />

public user: Observable;<br />

constructor(public store$: Store, private userService: UserService) {<br />

this.user = store$.select('user');<br />

}<br />

login(username: string) {<br />

this.userService.login(username);<br />

}<br />

}<br />

logout() {<br />

this.userService.logout();<br />

}<br />

As Ngrx is a merge of Redux and RxJs concepts, it can be quite hard to understand the ins an outs at the beginning.<br />

But this is a powerful pattern that allows you as we've seen in this example to have a reactive app and were you can<br />

easily share your data. Don't forget that there's a Plunkr available and you can fork it to make your own tests !<br />

I hope it was helpful even tho the topic is quite long, cheers !<br />

GoalKicker.com – <strong>Angular</strong> 2 Notes for Professionals 152

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!