effector icon indicating copy to clipboard operation
effector copied to clipboard

allow useStoreMap for shapes

Open xaota opened this issue 2 years ago • 1 comments

Proposal

const value = useStoreMap({
  shape: { a: $a, b: $b, c: $c }, // ! now param name is "store", proposal - rename to "shape" or "units"
  keys,
  fn
});
  • maybe rename this method to useShapeMap or useUnitMap оr useUnitMemo ?

Use case

now, we need a combined store for this cases: // model.ts

import { combine } from "effector";

export const $combined = combine({ a: $a, b: $b, c: $c })

// Component.tsx

import {$combined} from "./model.ts";

...
const value = useStoreMap({
  store: $combined,
  keys,
  fn
});

xaota avatar Mar 02 '23 09:03 xaota

I suppose we don't need to rename the whole hook:

const value = useStoreMap({
  source: { a: $a, b: $b, c: $c }, // Just rename the parameter. Or don't rename anything
  keys,
  fn
});

sergeysova avatar Mar 02 '23 10:03 sergeysova