Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
changed?: boolean; // value updates
touched?: boolean; // blured
visited?: boolean; // focused
error?: string;
}
export interface IFormState {
fields: Dictionary;
initials: TFormValues;
values: TFormValues;
submitting?: boolean;
}
export type TFormErrors = Dictionary;
export const FormActor = Actor.of("form");
export const formKey = (formName: string) => `${FormActor.group}::${formName}`;
const formKeyFromActor = (actor: Actor) => formKey(actor.opts.form);
export const formInitial = FormActor.named("initial").effectOn(formKeyFromActor, (_, { arg }) => ({
fields: {},
initials: arg,
values: cloneDeep(arg),
}));
export const formDestroy = FormActor.named("destroy").effectOn(formKeyFromActor, () => undefined);
export const formStartSubmit = FormActor.named("start-submit").effectOn(
formKeyFromActor,
(formState: IFormState) => ({import { Actor, useStore } from "@reactorx/core";
import { useMemo } from "react";
import { IStoreOpts, persistedKeys } from "./Persister";
const PersisterActor = Actor.of("persister");
const persist = PersisterActor.named("register").effectOn(persistedKeys, (state, { opts }) => ({
...state,
[opts.key]: opts || {},
}));
export const usePersist = (key: string, opts: Partial = {}) => {
const store$ = useStore();
// register persist key before all
// ugly but have to
useMemo(() => {
if (!(store$.getState()[persistedKeys] || {})[key]) {
persist
.with(undefined, {
...opts,import { Actor, useEpic, useStore } from "@reactorx/core";
import { History, LocationDescriptorObject, Path } from "history";
import { Observable } from "rxjs";
import { filter, ignoreElements, tap } from "rxjs/operators";
import { IRouterProps, Router } from "./Router";
import React, { useEffect, useMemo } from "react";
export const RouterActor = Actor.of("router");
export const routerActors = {
push: RouterActor.named