Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Remi Guittaut
    @remiguittaut
    when I need it in a class, I just set it as param to the constructor to get it injected
    Adam Warski
    @adamw
    yes
    Remi Guittaut
    @remiguittaut
    but it doesn't work, I get this thing about Function1 being a trait
    Adam Warski
    @adamw
    because you are doing wire[LocationLookup] :)
    which can't work
    you should pass localtionLookup instance as a paramtere
    you already have the instance created using wireWith
    Remi Guittaut
    @remiguittaut
    ok, how should I do then?
    Adam Warski
    @adamw
    same as every other parameter
    Remi Guittaut
    @remiguittaut
    yes in a class, but in an object?
    Adam Warski
    @adamw
    well if you want parameters you can't have an object
    Remi Guittaut
    @remiguittaut
    yes
    but I can access singletons registered in macwire from an object, can't I?
    Adam Warski
    @adamw
    there's no such thing as "registered in macwire"
    wire just creates a new instance
    or wireWith, same thing, just creates an instance
    now you can do with the instance whatever you want :)
    e.g. access from an object if that's needed
    and if the instance is of course accessible
    Remi Guittaut
    @remiguittaut
    ok, how do I access it?
    from an object
    Adam Warski
    @adamw
    well by name for example
    where's the locationLookup instance defined?
    Remi Guittaut
    @remiguittaut
    inside of the module
    Adam Warski
    @adamw
    well then you need an instance of the module
    but maybe an object is not what you are after, if you need it to access dynamic configuraiton
    if the module instance is dynamic in some way
    Remi Guittaut
    @remiguittaut
    ok
    Adam Warski
    @adamw
    there's nothing macwire-specific here really, these are normal Scala access rules
    macwire just helps you to create the instance
    Remi Guittaut
    @remiguittaut
    to be thorough: I have an object because it's just smth to map types with eachother
    Adam Warski
    @adamw
    note that you can also use wire outside of modules
    Remi Guittaut
    @remiguittaut
    now sometimes to map entities, we need to lookup other entities
    Adam Warski
    @adamw
    again, it just creates an instance
    no global registries etc
    Remi Guittaut
    @remiguittaut
    and I don't want any business code in there
    that's why I want injected lookup functions
    but if u say that it's not possible from an object (and I got the part about the macro just replacing by new xxx, or using apply), I will find another way
    Adam Warski
    @adamw
    ok, good luck :)
    Remi Guittaut
    @remiguittaut
    thx, didn't see your message yesterday
    so, to solve my problem I changed all the objects to classes
    BUT, I got a circular dependencies problem
    pretty wide circle, involving 6 types or smth
    how would you break that? I saw some guys using a "call by name" approach in constructors, but I'm not sure about how to do that
    Remi Guittaut
    @remiguittaut
    never mind, I found your test about call by name injections in ctors
    quite elegant approach actually
    Vít Brunner
    @tasuki
    I'm completely green, perhaps you can help me. I have a trait Search (part of model package) implemented by object AStar (search package), I'd like a case class Board (model package) to use Search and not be aware which implementation it's using. The class hierarchy is not that complicated, yet passing the Search object down the hierarchy would be quite nasty. What can I do?
    Adam Warski
    @adamw
    well you need to pass the search instance somehow - either as a constructor, or method parameter
    I'm afraid there isn't anything that's not "magical" that could help you :)
    Ivan Morozov
    @allquantor
    Cheers guys!