Skip to content

Instantly share code, notes, and snippets.

@evgenyfedorenko
Last active November 11, 2019 21:31
Show Gist options
  • Save evgenyfedorenko/8e2764dcbb38eeadbd6585d1f12d54be to your computer and use it in GitHub Desktop.
Save evgenyfedorenko/8e2764dcbb38eeadbd6585d1f12d54be to your computer and use it in GitHub Desktop.
export function createSelector(...args: any[]) {
const selectors = args.slice(0, args.length - 1);
const projector = args[args.length - 1];
return function (state: any) {
const args = selectors.map(fn => fn(state));
return projector.apply(null, args);
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment