Skip to content

Instantly share code, notes, and snippets.

@mayrascript
Created December 18, 2019 02:05
Show Gist options
  • Select an option

  • Save mayrascript/f5782004a839efb2c19ad42d0e796523 to your computer and use it in GitHub Desktop.

Select an option

Save mayrascript/f5782004a839efb2c19ad42d0e796523 to your computer and use it in GitHub Desktop.
import { Observable } from 'rxjs';
import { distinctUntilChanged, map } from 'rxjs/operators';
export function select(key: string) {
return (obs: Observable<{ [key: string]: any }>) =>
obs.pipe(
map(state => state[key]),
distinctUntilChanged()
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment