Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Jul 03 11:41
    cuilei5205189 starred dry-rb/dry-monads
  • Jul 02 11:26
    flash-gordon commented #97
  • Jul 01 09:55
    solnic opened #441
  • Jul 01 09:54
    solnic opened #242
  • Jun 30 17:02
    ahoward commented #97
  • Jun 30 17:01
    ahoward commented #97
  • Jun 30 16:58
  • Jun 30 09:01
    flash-gordon commented #97
  • Jun 30 03:07
    ahoward labeled #97
  • Jun 30 03:07
    ahoward opened #97
  • Jun 30 03:07
    ahoward labeled #97
  • Jun 28 13:44
  • Jun 28 10:17
    kroolp commented #83
  • Jun 28 07:49
    solnic commented #83
  • Jun 28 07:47
    solnic commented #84
  • Jun 27 16:07
    kroolp review_requested #84
  • Jun 27 16:07
    kroolp opened #84
  • Jun 27 16:05
    kroolp labeled #83
  • Jun 27 16:05
    kroolp labeled #83
  • Jun 27 16:05
    kroolp opened #83
François Bernier
@fbernier
alright
so if I have those kind of needs, should I be looking into virtus instead ?
Piotr Solnica
@solnic
@AMHOL wdyt about a feature in dry-container to memoize resolved object?
container.register(‘foo’, singleton: true) { Foo.new }
would that be too much?
I think it’s gonna be a common pattern that you only want to have one instance
Andy Holland
@AMHOL
@solnic just do container.register('foo', Foo.new)
Piotr Solnica
@solnic
I can’t in some places
becauase Foo.new may need Bar.new
Andy Holland
@AMHOL
If Foo#call is implemented, you'll need container.register('foo', Foo.new, call: false)
Fair point
Yep, I think we could add that interface
Piotr Solnica
@solnic
that would be awesome
it would give a speed boost
ie my current rails app has everything provided by the container, on each request we build a lot of objects and many of them can be singletons
like rom repos etc
Andy Holland
@AMHOL
Yeah, makes sense, I didn't think about that when I made the register('blah', Blah.new) interface, I think I might remove that
Piotr Solnica
@solnic
it shouldn’t be too hard to do on the container side and it would simplify things
Andy Holland
@AMHOL
Could probably simplify things if I remove that and the proc interface and only allow block registration with options
Piotr Solnica
@solnic
yes
Piotr Solnica
@solnic
@AMHOL it would also allow us to require files within the block
and it would be called just once
I basically want a way of having complete isolation wrt deps
Andy Holland
@AMHOL
Yeah, although that feels a bit wrong, dunno why lol
Piotr Solnica
@solnic
so ie I want to write a test, require only the container, and when I ask for a specific dep I know only min will be required and instantiated
I dunno, I had the same feeling initially, but now if kinda feels right
needs further thinking I suppose
Andy Holland
@AMHOL
Yeah, makes sense I guess
I just think it's better to require everything eagerly during setup
Piotr Solnica
@solnic
worth to experiment with this
when booting, YES OF COURSE
when loading a test, NO OF COURSE NOT
ie rspec spec/unit/foo_spec.rb should run in complete isolation
wrt deps
atm I require spec-helper which loads the app, this is nonsense
when I see “123421.214412341 seconds to load files” in the rspec output, I cry
Andy Holland
@AMHOL
lmao
Fair point
If you load in isolation, how do you know the method under test hasn't been monkey wrenched though?
Piotr Solnica
@solnic
wdym?
Andy Holland
@AMHOL
Forgot the :trollface:
lol
Monkey patched
Piotr Solnica
@solnic
sorry, didn’t get the joke, FUNNY :D
or scary, not sure
Andy Holland
@AMHOL
Yeah
It's funny because it's true
Piotr Solnica
@solnic
right :)
I can now see what changes are needed to achieve isolation
I need to separate container configuration from finalization