Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Stevo Slavić
    @sslavic
    hi there
    I'm considering to use macwire
    Stevo Slavić
    @sslavic
    init and wiring works nice
    is there any support for other module lifecycle events, like close?
    Adam Warski
    @adamw
    no, you'd have to do it yourself
    as there's no container the module doesn't really have any "managed" lifecycle beyond creation :)
    but you could e.g. add a close() method to your module and there do any cleanup
    Stevo Slavić
    @sslavic
    ok, clear, thanks
    maybe a macro or something is possible
    which I could use in close method of a module
    which would inspect all vars of module, and ones which implement e.g. AutoClosable, code would be generated that calls close on them
    and respect order of instantiation, to call close in reverse order
    Adam Warski
    @adamw
    yeah more generally something that returns a set/list of all members that are a subtype of a given type
    I think there's an issue for that ...
    quite old even :) #8
    Stevo Slavić
    @sslavic
    cool
    could filter, and map in close
    foreach
    for each AutoClosable, call close
    but without this order constraint, that they get closed inverse to order of instantiation
    Adam Warski
    @adamw
    that could be tricky
    to get the order of instantiation
    and what about a method
    registerForClosing(t: T): T
    in which all values which require closing would have to be wrapped
    that would capture the correct order
    the registerForClosing would add the instance to a list and return it unmodified
    Stevo Slavić
    @sslavic
    wire macro could generate those registerForClosing calls automatically, given condition is met that object is a subtype of AutoClosable
    Adam Warski
    @adamw
    true :)
    Yves Müller
    @slomo
    I have usecase question for the wire macro. Most of my Compontents take configuration options (eg. Database name) and other components (eg. Excution context) as a parameter. Now I'd like to use wire in order to provide the components but not the configuration options. Is that even possible?
    My rational is that most of the config options are Strings so that would require to tag them all ... which would result in basically writing down a copy of the config file it self mapping all the paths in the config like "system1.database.name" to tags like "System1DatabaseName"