Newer
Older
/* eslint react/prop-types: 0 */
/* eslint react/destructuring-assignment: 0 */
});
export default props => {
const [context, setContext] = useState({
app: props.app,
activeView: props.activeView || {},
activeViewId: props.activeViewId || {},
transaction: {},
setTransaction: tr => {
Object.assign(context.transaction, tr);
},
setOption: option => {
Object.assign(context.options, option);
},
const pmViews = Object.assign(context.pmViews, newView);
const activeView = pmViews[activeViewId || context.activeViewId];
}}
>
{props.children}
</WaxContext.Provider>
);
};
export const useInjection = identifier => {
const {
app: { container },
} = useContext(WaxContext);
if (!container) {
throw new Error();
}
return container.isBound(identifier)
? { instance: container.get(identifier) }
: null;
};
export class Service {
setApp(app) {
this.app = app;
}
get container() {
return this.app.container;
}
get config() {
return this.app.config.get(`config.${this.name}`) || this.app.config;
}
get schema() {
return this.app.getSchema();
}
}