Documentation / @zerotal/flow / index / registerFlowModel
Function: registerFlowModel()
registerFlowModel(
name,ModelClass):void
Defined in: flow/src/synths/ModelSynth.ts:39
Register an ORM model class under a stable name so the model synth can send it
across the wire: a model prop is dehydrated to its id (tagged with this name)
and hydrated back by re-fetching via findOrFail.
Parameters
name
string
Stable, developer-assigned name recorded in the snapshot's meta.class.
ModelClass
typeof BaseModel
The BaseModel subclass to associate with name.
Returns
void
Remarks
Registering by an explicit name (rather than constructor.name) keeps snapshots
valid under minification, where the class name may be mangled. You normally don't
call this directly — declare models in a component's static models map and the
framework registers them when the page is registered.
Example
class ShowPost extends Component {
static models = { Post }; // auto-calls registerFlowModel("Post", Post)
@locked post!: Post; // survives the round-trip as a rehydrated model
}
// Or register manually (e.g. outside a page's static models):
registerFlowModel("Post", Post);