Search code examples
webconstructorweb-componentnim-lang

Component Constructors In HappyX


It possible to create custom component constructor in happyx web framework? For example:

component A:
  field: int
  
  constructor(args):
    ...

Solution

  • Yeap, it possible. Few hours ago this issue was closed in HappyX repo.

    So to declare constructor you need

    component A:
      field: int
      constructor(a: int):
        self.field = a*5
    

    And usage is

    appRoutes "app":
      "/":
        component A->construct(a = 10)