macwire
macwire copied to clipboard
Support function defs as function values (for factory dependencies)
It would be nice if function defs were automatically converted to function values.
So that with the following class:
class PlatformsPage(store:PlatformStore,platformBackend:(BackendScope[Props,State] => Backend))
You could wire its dependencies with a module like:
trait PlatformsModule {
lazy val platformsPage = wire[PlatformsPage]
lazy val platformsStore = wire[PlatformStore]
def platformsBackend(scope:BackendScope[Props,State]):Backend = new Backend(scope)
}
There are easy alternatives:
lazy val platformsBackend:BackendScope[Props,State] => Backend = new Backend(_)
type BackendFactory = BackendScope[Props,State] => Backend
lazy val platformsBackend:BackendFactory = new Backend(_)
But given that defs are used with MacWire, it seems like it would be nice to support function defs as function value dependencies.