Skip to content

doasync/effector-kit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NPM Version NPM Downloads GitHub issues

Effector kit

🧰


Installation

npm install effector effector-kit

or

yarn add effector effector-kit

Usage

getVoid:

sample({
  source: initMapFx.done,
  fn: getVoid,
  target: createPopupFx,
});

getInverted:

sample({
  source: $loader,
  clock: guard($pending, { filter: getInverted }),
  target: removeLoaderFx,
});

setPayload:

$countries.on(fetchCountriesFx.doneData, setPayload);
$schoolId.on(changeSchoolId, setPayload);

Helpers

export const getVoid = (payload?: unknown): void => undefined;
export const getInverted = (payload: unknown): boolean => !payload;
export const setBoolean = (state: unknown, value: unknown): boolean =>
  Boolean(value);
export const setTrue = (state?: unknown, payload?: unknown): true => true;
export const setFalse = (state?: unknown, payload?: unknown): false => false;
export const setNull = (state?: unknown, payload?: unknown): null => null;
export const setPayload = <Payload = unknown>(
  state: unknown,
  payload: Payload
): Payload => payload;