I’ve got a pretty generic GenServer that I’ve created that I want to use in a few contexts. In each context, there’s a specific function that the component will have to call, but I want the specific implementation to be different for each instance. I’m still new to elixir, so I may be wrong with this, but I figure I have the following options:
- pass the function as an init arg to the component
- Make a bass component and then override the specific behaviour by subclassing via “use” in the same way that I currently ‘sub-class’ genserver via “use” (How do I properly phrase this? It feels like ‘subclassing’ but there’s probably a proper way to say this.
Also, in general, are there any problems with passing functions/closures between processes? Would it still work in a distributed Elixir environment?