Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Jisoo Park
    @guersam
    Just opened adamw/macwire#82
    Renato Cavalcanti
    @renatocaval
    Hi guys, do any of you have encountered issues play logging and macwire?
    If I use this example: https://github.com/adamw/macwire#play24x, logging get muted
    I don’t think the problem resides in macwire, but in extending Play’s ApplicationLoader
    My impression is that somehow the logging configuration won't be loaded
    Renato Cavalcanti
    @renatocaval
    Ok, this it the trick
    when using macwire with play, make sure you configure the logging as such:
    class AppApplicationLoader extends ApplicationLoader {
      def load(context: Context) = {
    
        Logger.configure(context.environment)
    
        (new BuiltInComponentsFromContext(context) with AppComponents).application
      }
    }
    without that you’ll get nothing in your logs
    will send a PR to the README file and example/play24
    Stevo Slavić
    @sslavic
    hi there
    I'm wondering what are some tried good practices macwire users apply to pass configuration properties during wiring
    Adam Warski
    @adamw
    I'm using traits which read from typesafe config sub-Config objects
    so a regular type :)
    Aleksandrov Vladimir
    @invis87
    Hello everyone!
    I have a question about using Play+Macwire+Akka
    How can I inject Play's ActorSystem with macwire?
    in documentation they says "import play.api.libs.concurrent.Akka"
    it is works, but not with Macwire...
    Adam Warski
    @adamw
    what's the contructor that you are trying to wire? maybe you can share a code fragment showing what you try to do?
    Aleksandrov Vladimir
    @invis87

    Actually it is working now :)

    import play.api.Play.current
    import play.api.libs.concurrent.Akka

    trait ActorsModule {

    lazy val actorSystem = Akka.system
    }

    this module is fine. The problem was here

    object Global extends GlobalSettings with Macwire {

    val wired = wiredInModule(Application)

    override def getControllerInstanceA = wired.lookupSingleOrThrow(controllerClass)
    }

    I made wired lazy and all goes fine :)

    Adam Warski
    @adamw
    ah, great to hear :)
    so it was the initialization order
    common with lazy vals :)
    Aleksandrov Vladimir
    @invis87
    indeed :)
    Aleksandrov Vladimir
    @invis87
    One more question ^^
    If I have a class (PostgreDB for example) that use DBPoolActor for operations. How can I inject it?
    I can't write like this:
    class PostgreDatabase(dbPoolActor: ActorRef)
    because I have more than one Actors in my system that I want to inject
    Looks like I should use tags
    Aleksandrov Vladimir
    @invis87
    buuuuut I dont understand how use it properly
    I have:
    import play.api.Play.current
    import play.api.libs.concurrent.Akka
    
    trait ActorsModule {
    
      lazy val actorSystem = Akka.system
      lazy val dbPoolActor = actorSystem.actorOf(Props(wire[DBPoolActor])).taggedWith[DBPoolActor]
    }
    and DB
    class PostgreDatabase(dBPoolActor: ActorRef @@ DBPoolActor) extends Database { ...
    }
    But how my DatabaseModule should looks like???
    trait DatabaseModule {
      lazy val database: Database = ???
    }
    Aleksandrov Vladimir
    @invis87
    When I am trying
    lazy val database: Database = new PostgreDatabase(wire[ActorRef @@ DBPoolActor])
    I get error
    Compilation error[Cannot find constructor for WeakTypeTag[com.softwaremill.macwire.@@[akka.actor.ActorRef,actors.DBPoolActor]]]
    Aleksandrov Vladimir
    @invis87

    hmmm, looks like I understand :)

    trait DatabaseModule extends ActorsModule {
      lazy val database: Database = wire[PostgreDatabase]
    }

    this works fine

    Adam Warski
    @adamw
    :) yes, that's how you should use tags
    Erik LaBianca
    @easel
    are macwire builds for scala.js kept up to date? I’m seeing unresolved dependency: com.softwaremill.macwire#macros_sjs0.6_2.11;2.2.0: not found adding it with %%%
    Adam Warski
    @adamw
    I don't think there ever was a dedicated scala js build
    doesn't it work using just %%?
    Adam Warski
    @adamw
    @easel I just updated the scalajs example to newest of everything and I think it works fine with %%, no dedicated build neeeded, see: https://github.com/adamw/macwire/tree/master/examples/scalajs
    Erik LaBianca
    @easel
    Ah silly me. It’s compile-time only, I suppose so no %%% needed. Thanks =p
    Adam Warski
    @adamw
    hmm there are some runtime components as well, I'm not very familiar with scala-js , maybe these runtime would need to be published specially for scala-js
    Erik LaBianca
    @easel
    I’d expect the runtime stuff would need to be. If it’s not “known to work” I can pull down the sources and fiddle with it, it should be just a matter of publishing the cross build.
    Adam Warski
    @adamw
    @easel that would be great - I don't think it's "known to work". The runtime components are: util (no deps), and proxy, that however depends on javassist - I'm not sure if that would work in Scala.JS, but again, I didn't try :)
    Erik LaBianca
    @easel
    Ok sounds good. My hunch is that proxies in javascript would need to be handled differently. I’ll reach out here once I have a second to poke at it.
    Artyom Kozhemiakin
    @akozhemiakin
    Hi guys! I wonder if there is any automatic way to inject multiple dependencies implementing the same interface (extending the same trait) in a form of a List (or Set, or other collection, or even shapeless HList) using macwire? I'm talking about some functionality more or less similar to the multibinding in Guice
    Artyom Kozhemiakin
    @akozhemiakin
    Ok, it seems that I eventually encountered what I'v searched for in the source code and it is "wireSet" method. Also it is not documented and I'm not quite sure how to use it properly.
    Artyom Kozhemiakin
    @akozhemiakin
    I'v created the pull request to add HList injection support: adamw/macwire#88
    Ilya Epifanov
    @ilya-epifanov
    Hi guys, can I wire some parameters with macwire but provide remaining ones with implicits manually?
    Like this: def strategy1()(implicit staticsContext: StaticsContext, param1: Param1) = wire[Strategy1]
    class Strategy1 @Inject() (val service1: Service1, val service2: Service2)(implicit staticsContext: StaticsContext, param1: Param1) { ... }
    Or should I separate this into two classes?
    Ilya Epifanov
    @ilya-epifanov
    Ok, I've tested this, it works fine:)
    Rafal Wachol
    @charafau

    hello! I am doing some programming with scala on android and I thought about using macwire. Everything works nicely but I got stuck with injecting class which depends on the other one extending module. Example:

    class ChatPresenter(chatContractView: ChatContractView) extends ChatContractPresenter { }
    
    trait ChatModule {
      import com.softwaremill.macwire._
    
      lazy val presenter: ChatContractPresenter = wire[ChatPresenter]
    
    }
    
    class ChatFragment extends BaseFragment  with ChatModule { pesenter. ..... }

    So I want to use ChatPresenter in ChatFragment. How can I achieve this ?

    Rafal Wachol
    @charafau
    ok, I resolved my problem, in case someone will have the same problem, I'm leaving solution here:
    trait ChatModule {
      import com.softwaremill.macwire._
    
      def presenter(chatContractView: ChatContractView) : ChatContractPresenter = wire[ChatPresenter]
    
    }
    
    class ChatFragment extends BaseFragment
      with ChatContractView
      with ChatModule {
    
      val chatPresenter = presenter(this)
    }