Can an extension add a notifier/fragment?

Quick poke leads me to believe this is the same as asking whether an extension can add other extensions, since notifiers and fragments are just special kinds of extensions.
12 Replies
ZachDaniel
ZachDaniel2y ago
I don't believe it can do so currently, but you could validate that another extension had been added additionally, notifiers are just a type of extension so if your extension is a notifier, you can do notifiers: [YourExtension]
\ ឵឵឵
\ ឵឵឵OP2y ago
I'd like my extension to build a notifier and add it.
frankdugan3
frankdugan32y ago
Is AshAuthentication a relevant example to this question? :thinkies:
ZachDaniel
ZachDaniel2y ago
not so much in this case @\ ឵឵឵ we'll need to add that as a feature in spark in that case. Actually, come to think of it, does your notifier have a DSL? If not, you can modify the resource.simple_notifiers option you can use Ash.Resource.Info.simple_notifiers(dsl) to get the list and then set it with Transformer.set_option or set_opt or w/e its called, I forget 😄
\ ឵឵឵
\ ឵឵឵OP2y ago
Righto, that'll work perfectly for my immediate case. Definitely had some thoughts about fragments as well, but think there might be some issues there anyways with regards to supplying parameters. Thanks!
ZachDaniel
ZachDaniel2y ago
Yeah, but there isn't a way to dynamically add a fragment to a resource either 😆 So would still need to be a spark feature
\ ឵឵឵
\ ឵឵឵OP2y ago
Ofc. First take on how tough it would be to let extensions append other extensions? Wouldn't imagine which key they are passed with makes much of a difference 😄 For transformers, I guess it's allowing the extension to return further extensions to be added to the list of transform passes.
ZachDaniel
ZachDaniel2y ago
hmm....it would need to be like a special callback on the extension it would almost certainly not be doable in a transformer because we're basically at the end of the process by then
\ ឵឵឵
\ ឵឵឵OP2y ago
Ah, I mean extensions using transformers. Gotcha
ZachDaniel
ZachDaniel2y ago
But we could support a callback in the extension module like def add_extensions(entity), do: ... and that probably wouldn't be too bad
\ ឵឵឵
\ ឵឵឵OP2y ago
I think that would be pretty reasonable, just means building the notifier module in that callback (or before, as the case may be). I wanted to build the notifier module based on parameters in the DSL, though, which was why I thought of the transformers, but there may be ways to get around that. I can have the notifier be static and have it pull the DSL stuff out of the resource passed with each notification call, for example.
ZachDaniel
ZachDaniel2y ago
Yeah I’d do that 🙂

Did you find this page helpful?