UNPKG

mobx-view-model

Version:
19 lines (18 loc) 579 B
import { makeObservable } from 'mobx'; export const applyObservable = (context, annotationsArray, observableConfig) => { if (observableConfig.custom) { return observableConfig.custom(context, annotationsArray); } if (observableConfig.disableWrapping) { return; } if (observableConfig.useDecorators) { annotationsArray.forEach(([field, annotation]) => { annotation(context, field); }); makeObservable(context); } else { makeObservable(context, Object.fromEntries(annotationsArray)); } };