defineTrait
Call Signature
Section titled “Call Signature”defineTrait(
name,schema,options):PredictedTrait<Record<string,never>>
Makes a trait, as koota’s trait does, and names it: the dump and the
devtools show it under name, and a room streams it to every page.
The options are optional: ownerOnly streams it to its character’s
player alone, serverOnly keeps it on the room, local has the room
and each page keep their own, and predicted has her page predict it
on her character. A trait with a field that holds an entity, or a list
of them, takes options, whose entities names each such field. A
predicted trait is a PredictedTrait, which only a predicted step and
grantPredicted write, unless anyEntity keeps it koota’s own. With no
schema it is a tag. Called once, at module scope, in a module the room
and the page both import. The common call is an ordinary trait,
defineTrait("score", { points: 0 }), the last signature here; this
one makes a predicted tag.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
name |
string |
schema |
undefined |
options |
PredictedTraitOptions<never, never> |
Returns
Section titled “Returns”PredictedTrait<Record<string, never>>
Call Signature
Section titled “Call Signature”defineTrait<
S,Listed>(name,schema,options):PredictedTrait<Norm<S>>
A predicted trait with fields, as its options say.
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
S extends Schema |
- |
Listed extends string |
never |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
name |
string |
schema |
S & RefusePlayerText<S> |
options |
PredictedTraitOptions<TraitRecord<S>, Listed> |
Returns
Section titled “Returns”PredictedTrait<Norm<S>>
Call Signature
Section titled “Call Signature”defineTrait(
name,schema?,options?):TagTrait
A tag: a trait with no fields.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
name |
string |
schema? |
undefined |
options? |
TraitOptions<never, never> & PlainTraitOptions |
Returns
Section titled “Returns”TagTrait
Call Signature
Section titled “Call Signature”defineTrait<
S,Listed>(name,schema, …options):Trait<Norm<S>>
A trait with fields that is not predicted, or is predicted with
anyEntity: koota’s own trait.
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
S extends Schema |
- |
Listed extends string |
never |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
name |
string |
schema |
S & RefusePlayerText<S> |
…options |
PlainOptionsArgument<TraitRecord<S>, Listed> |
Returns
Section titled “Returns”Trait<Norm<S>>