@envelop/core
Version:
This is the core package for Envelop. You can find a complete documentation here: https://github.com/n1ru4l/envelop
26 lines (25 loc) • 741 B
JavaScript
export const useEngine = (engine) => {
return {
onExecute: ({ setExecuteFn }) => {
if (engine.execute) {
setExecuteFn(engine.execute);
}
},
onParse: ({ setParseFn }) => {
if (engine.parse) {
setParseFn(engine.parse);
}
},
onValidate: ({ setValidationFn, addValidationRule }) => {
if (engine.validate) {
setValidationFn(engine.validate);
}
engine.specifiedRules?.map(addValidationRule);
},
onSubscribe: ({ setSubscribeFn }) => {
if (engine.subscribe) {
setSubscribeFn(engine.subscribe);
}
},
};
};