ember
ember copied to clipboard
Add section for Higher Order Types
Higher Order Types are functions that return a type. They're useful when you have many similar types with some variation and you want the same component to be able to consume these types.
For example, a node type could take content as a value. It would look like this,
export function NodeOf(Content) {
return class Node {
content = Content;
isOpen = Boolean;
children = [Node];
addChild() {
return this.children.push({}).isOpen.set(true);
}
}
}
export default NodeOf(Number);
We need to describe this in better detail. Questions to answer:
- When is this useful?
- How should this be used?