mobx-view-model
Version:
MobX ViewModel power for ReactJS
19 lines (18 loc) • 579 B
JavaScript
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));
}
};