...
@@ -53,8 +59,8 @@ The `component()` call itself returns a function that creates an instance of the
To create a component, you need to create the component object and register it using one of the provided helpers.
Component objects can be:
-- functions returning plain objects
- classes
+- functions returning plain objects
In the context of plain objects, the wrapper function acts as a constructor that can pass initial data to the object.
@@ -98,7 +104,7 @@ registerComponents(files);
You can create class components by extending `AlpineComponent` and exporting the class as `default`.
-The `AlpineComponent` provides IDE support for Alpine's magic properties. This means that you can use `this.$el`, `this.$nextTick(() => this.foo = this.bar)`, and more with full type support.
+`AlpineComponent` provides full IDE support for Alpine's magic properties. This means that you can use `this.$el`, `this.$nextTick(() => this.foo = this.bar)`, and more with perfect type enforcement.
```ts
import { AlpineComponent } from '@leanadmin/alpine-typescript';
@@ -134,7 +140,7 @@ export default class DarkModeToggle extends AlpineComponent {
## Plain object components
-To register a plain object as an Alpine component, return a function that wraps the object like this:
+To register a plain object as an Alpine component, export a function that wraps the object like this:
```ts
export default (foo: string, bar: number) => ({
foo,
@@ -146,7 +152,7 @@ export default (foo: string, bar: number) => ({
})
```
-The function will serve as a "constructor" for the object, setting default values and anything else you might need.
+The function will serve as a "constructor" for the object, setting default values and anything else that's needed.
Note that the `=> ({` part is just syntactic sugar, you're free to use `return` if it's useful in your case: