Skip to content

Commit f2dc345

Browse files
committed
Updates
1 parent e639595 commit f2dc345

File tree

1 file changed

+54
-17
lines changed

1 file changed

+54
-17
lines changed

text/1099-renderComponent.md

Lines changed: 54 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,48 @@ Users would import `renderComponent` from `@ember/renderer` (a pre-existing modu
4646

4747
The interface:
4848
```ts
49+
/**
50+
* Renders a component into an element, given a valid component definition.
51+
*/
4952
export function renderComponent(
50-
component: object,
51-
{
52-
owner,
53-
env,
54-
into,
55-
args,
56-
}: {
57-
owner?: object;
58-
env?: { document?: SimpleDocument | Document; isInteractive?: boolean; };
59-
into: IntoTarget;
60-
args?: Record<string, unknown>;
53+
/**
54+
* The component definition to render.
55+
*
56+
* Any component that has had its manager registered is valid.
57+
* For the component-types that ship with ember, manager registration
58+
* does not need to be worried about.
59+
*/
60+
component: object,
61+
options: {
62+
/**
63+
* The element to render the component in to.
64+
*/
65+
into: IntoTarget;
66+
67+
/**
68+
* Optional owner. Defaults to `{}`, can be any object, but will need to implement the [Owner](https://api.emberjs.com/ember/release/classes/Owner) API for components within this render tree to access services.
69+
*/
70+
owner?: object;
71+
72+
/**
73+
* Configure the `document` and `isInteractive`
74+
*/
75+
env?: {
76+
/**
77+
* Defaults to globalThis.document.
78+
*/
79+
document?: SimpleDocument | Document;
80+
81+
/**
82+
* When false, modifiers will not run.
83+
*/
84+
isInteractive?: boolean;
85+
};
86+
87+
/**
88+
* These args get passed to the rendered component
89+
*/
90+
args?: Record<string, unknown>;
6191
}
6292
): RenderResult | undefined {
6393
/* ... implementation details ... */
@@ -70,13 +100,19 @@ It's shape is:
70100
```ts
71101
export interface RenderResult {
72102
/**
73-
* The element rendered in to
74-
*/
75-
parentElement(): SimpleElement;
103+
* The element rendered in to
104+
*/
105+
parentElement(): SimpleElement;
106+
107+
/**
108+
* Destroys the render tree and removes all rendered content from the element rendered into.
109+
*/
110+
destroy(): void
111+
76112
/**
77-
* Re-renders the component
78-
*/
79-
rerender(options?: { alwaysRevalidate: false }): void;
113+
* Re-renders the component
114+
*/
115+
rerender(options?: { alwaysRevalidate: false }): void;
80116
}
81117
```
82118

@@ -173,6 +209,7 @@ Here is where this RFC differs:
173209
- document is optional and defaults to `globalThis.document`
174210
- env is optional (as all its contents are optional)
175211
- owner is optional and defaults to a private empty object (`{}`)
212+
- returned object from `renderComponent` also has `destroy` on it, for convenience
176213

177214
## Unresolved questions
178215

0 commit comments

Comments
 (0)