Effect CommunityEC
Effect Community7mo ago
2 replies
Storm

Function to Retrieve Annotations for All Properties of a Struct Schema

so I see some documentation on creating a function to get a specific annotation (by symbol) for a specific schema (by ast), but is there a way to create a function to get an annotation for all properties of a struct schema?

For example:
export class PlayerState extends Schema.Class<PlayerState>("PlayerState")({
  name: Schema.NonEmptyString,
  baseHealth: Schema.Int,
  health: Schema.Int,
  baseEnergy: Schema.Int,
  energy: Schema.Int,
  deck: Schema.Array(CardState).annotations({ [Visibility]: "private" }),
  discard: Schema.Array(CardState).annotations({ [Visibility]: "private" }),
  hand: Schema.Array(CardState).annotations({ [Visibility]: "private" }),
  field: Schema.Array(CardState).annotations({ [Visibility]: "private" }),
})

const getPlayerStateView = (state: PlayerState, visibility: "private" | "public") =>
  // ???
Was this page helpful?