avocado-old/packages/entity/index.hooks.js
2020-06-25 07:44:13 -05:00

34 lines
864 B
JavaScript

import {mapObject} from '@avocado/core'
export function behaviorTypes() {
return {
entity: (entity) => {
const {allTraits} = require('./trait/registrar');
const Traits = entity
? Object.values(entity.allTraitInstances()).map((instance) => instance.constructor)
: allTraits();
const core = {
children: {
invokeHook: {
type: 'object',
label: 'Invoke hook.',
args: [
['hook', {
type: 'string',
}],
],
},
}
};
return Traits
.reduce((r, T) => ({
...r, children: {
...r.children,
...T.behaviorTypes(),
...mapObject(T.describeState(), (spec) => ({...spec, type: `property|${spec.type}`})),
},
}), core);
},
};
}