ember icon indicating copy to clipboard operation
ember copied to clipboard

Add section for Higher Order Types

Open taras opened this issue 5 years ago • 0 comments

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:

  1. When is this useful?
  2. How should this be used?

taras avatar Nov 27 '18 14:11 taras