On 12 February 2016 at 22:55, Merlijn Sebrechts
<merlijn.sebrec...@gmail.com> wrote:
> Hi all
>
>
> We have a layer that can install a number of different packages. It decides
> at runtime which packages will be installed. This layer uses the `apt` layer
> which sets a state `apt.installed.<packagename>`.
>
> We want to react to this installed state, but we don't know what the
> packagename will be beforehand. This gets decided at runtime. Therefore, we
> can't put it in a @when() decorator.
>
> Is there a way to dynamically register handlers at runtime?

Not with reactive as it stands, unless by 'at runtime' you mean 'at
import time'.

I previously patched @when_file_changed to accept callables, allowing
the filenames to be generated at run time. I imagine the same thing
would need to be done for the @when and @when_not decorators.

I'd experiment by creating your own decorator, and if it turns out to
be useful propose it as a charms.reactive update.

-- 
Stuart Bishop <stuart.bis...@canonical.com>

-- 
Juju mailing list
Juju@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/juju

Reply via email to