UNPKG

@schemeless/event-store-react-native

Version:

React Native compatible build of the [`@schemeless/event-store`](../event-store) runtime. It mirrors the Node.js implementation but swaps the internal queue implementation to [`react-native-better-queue`](https://github.com/YahyaASadiq/react-native-better

16 lines (14 loc) 605 B
import type { CreatedEvent, EventFlowMap } from '@schemeless/event-store-types'; import { getEventFlow } from '../operators/getEventFlow'; import { apply } from './apply'; import { validate } from './validate'; import { preApply } from './preApply'; export const makeValidateAndApply = (eventFlowMap: EventFlowMap) => async (event): Promise<CreatedEvent<any>> => { const eventFlow = getEventFlow(eventFlowMap)(event); await validate(eventFlow, event); const preAppliedEvent = await preApply(eventFlow, event); await apply(eventFlow, preAppliedEvent); return preAppliedEvent; };