1.0.0 • Published 4 years ago

the-selectors v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

the-selectors

Refine the selectors in TypeScript context.

  • Type-safe, the basic requirement of TS.
  • Simple, only one API, defineSelector.
  • Smart Type Inference, you have no need to write extra type annotations.
  • Free from Define Order, you can define the selectors in any order.

To create / define a selector:

import { defineSelector } from "the-selectors";

const aSelector = () => 1; // always returns 1
const bSelector = () => 2; // always returns 2
const cSelector = defineSelector(
  () => ({ a, b }),
  x => x.a + x.b,
); // should always returns 3, and the combiner will be evaluate only once. (Memoized)