Skip to content

Instantly share code, notes, and snippets.

@tomastrajan
Created May 1, 2017 11:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomastrajan/5aaaf3a42b001168d692e2eb3feeff10 to your computer and use it in GitHub Desktop.
Save tomastrajan/5aaaf3a42b001168d692e2eb3feeff10 to your computer and use it in GitHub Desktop.
Angular Model Pattern - combine state from multiple models
/* session and clients models in some component or service */
const filteredClients$ = this.sessionService.session$
.combineLatest(this.clientService.clients$)
.map(([session, clients]) => clients.filter(client => {
if (client.vip && session.accessVips) {
return true;
} else if (!client.vip) {
return true;
}
return false;
}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment