Components
Public state
Section titled “Public state”Class attributes that are not methods become public properties (snapshotted, checksummed, syncable):
class Search(Component): query = "" page = 1 query_string = ["query", "page"]Lifecycle
Section titled “Lifecycle”| Hook | When |
|---|---|
mount() |
First create |
hydrate() |
After snapshot restore |
booted() |
After mount/hydrate |
dehydrate() |
Before snapshot |
rendering() / rendered(html) |
Around Prism render |
Actions
Section titled “Actions”def save(self) -> None: self.validate() self.dispatch("saved", id=self.id)
def quiet(self) -> None: self.do_work() self.renderless() # no HTML morphCall from the browser with wire:click="save", wire:click="add(1)", or
$wire.save().
Validation
Section titled “Validation”from pydantic import BaseModel, Field
class Rules(BaseModel): label: str = Field(min_length=1)
class Form(Component): label = "" rules = Rules
def save(self) -> None: self.validate()Errors land in component.errors / $errors / effects.errors.
Nested components
Section titled “Nested components”@conduit('counter')@conduit('forms.profile', user_id=user.id)Lazy / defer
Section titled “Lazy / defer”class Heavy(Component): lazy = True # load when scrolled into view # defer = True # load on next frame after paint lazy_placeholder = "conduit.placeholders.spinner"