Allow wiring of a theme object without an Enum definition

Created on 1 August 2024, 6 months ago

Problem/Motivation

Generally in the Pinto setups I've seen we have a ProjectList enum which has cases for each theme object. Those cases contain a reference to the Definition (the theme object), dependencies on libraries, and some way to tie to the theme object to the template.

Why can't all this be derived from the Theme object itself? If I could put the dependencies and template attributes on my Theme object itself then everything is encapsulated in 1 spot and I don't have the extra step of adding the Enum case. IMO this would be a great DX improvement. However, I do not know if this is possible.

Proposed resolution

Remaining tasks

API changes

✨ Feature request
Status

Active

Version

1.0

Component

Code

Created by

🇦🇺Australia acbramley

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @acbramley
  • 🇦🇺Australia dpi Perth, Australia

    Trouble is Pinto as it is, is flexible so you can have objects located anywhere. If you look into internals, you’ll find the file name of the class is picked up with reflection. Even outside of regular src/ discovery. It’s not efficient to scan every directory in a project, so this is what we have.

    A solution could be to have a rigid, scanned directory/namespace just like Pinto enums do right now.

    This is kinda related to https://github.com/dpi/pinto/issues/4, putting all the metadata in the enum. Maybe solves issues with metadata spread all over? So your objects become purely about input/output.

  • 🇦🇺Australia acbramley

    I personally feel like all this information belongs on the theme object and would be totally fine with a constrained namespace (allowing for sub namespaces too) if that would unlock it.

  • 🇦🇺Australia dpi Perth, Australia

    We can support this scenario alongside existing.

    Pinto/Objects namespace?

    Probably configurable alongside the existing namespace container parameter.

    Should a new attribute register a class as an object, or pick up the existing attribute?

    I’m sure there are internal design issues that need to be resolved in order to couple from enums, while keeping existing functionality.

  • 🇦🇺Australia dpi Perth, Australia

    I am concerned on how we’d approach dealing with the things enums do for us. It do you imagine an object class magically gets bound to an enum, without an explicit Definition attr, or something?

  • 🇦🇺Australia acbramley

    Should a new attribute register a class as an object, or pick up the existing attribute?

    Maybe the ThemeDefinition would be enough?

    I am concerned on how we’d approach dealing with the things enums do for us.

    You mean the other things like templateDirectory etc?

  • 🇦🇺Australia dpi Perth, Australia

    In the meantime, Enum still remains the backbone to which everything derives. However new features (in 0.2.0) make enum more more important, including allowing the posibility of metadata like #[ThemeDefinition], and the new #[Slots] to be placed on the enum case or enum class itself.

    Assets are also a possibility...

Production build 0.71.5 2024