Genie Discord forum

Author AvatarWheredNateGo
5/25/2023, 2:50:58 AM

Hey everyone, is it possible with the new Reactive API to use a macro to reuse a block of fields for multiple models?

For example, can I create a macro somehow that will pass

universalfield1::String = "field1"
universalfield2::String = "field2"
universalfield3::String = "field3"

into this:

@vars Model1 begin
  @universalFieldsMacro # ???
  field4::String = "field4"
end

and also elsewhere into this:

@vars Model2 begin
  @universalFieldsMacro # ???
  field5::String = "field5"
end

I can't seem to crack it. I had something working before moving to the new API but I don't know enough about metaprogramming to adjust. Is it possible? Is there a better way?

Thanks!

Author AvatarPere
6/13/2023, 5:39:33 PM

you could try putting all universalfield strings into a UniversalFields struct, and then use that within @vars