These are chat archives for krisleech/wisper

15th
Aug 2017
Kris Leech
@krisleech
Aug 15 2017 09:48
@cored sorry, only just saw this message. I'm not sure I have tried, but you should be able to have an object be both listener and publisher. Do you have some code you can share?
Rafael George
@cored
Aug 15 2017 12:19
@krisleech oh no, sorry at least not at the moment
Kris Leech
@krisleech
Aug 15 2017 12:20
@cored no worries, if you have any further issues, it might be best to open a stackoverflow issue :)
Rafael George
@cored
Aug 15 2017 12:20
sure thing
I'll do that. I was about to not use wisper directl since I wwanted to give dry-transaction a try
however I don't see an easy way to test the triggering of events from a dry-transaction object; I tried with wisper-rspc since they use wisper under the hood but I gave up at some point and probably back to wisper again
Kris Leech
@krisleech
Aug 15 2017 12:23
I think wisper-rspec will only work for dry-transaction if you can get the actual publisher. It might not an object you own. Not sure...
Rafael George
@cored
Aug 15 2017 12:23
interesting
I tried with just tryigering the dry-transaction defined method and then in the block assert whatever I needed
Kris Leech
@krisleech
Aug 15 2017 12:24
The other thing to be careful of is dry-trans removing wisper as a dependency :)
Rafael George
@cored
Aug 15 2017 12:24
right
make sense, yes probably not a good approach to try to test directly the internals
maybe I should just subscribe to the event I want to assert on the result
Kris Leech
@krisleech
Aug 15 2017 12:25
using just wisper or dry-trans?
Rafael George
@cored
Aug 15 2017 12:25
I can test like that with both
Kris Leech
@krisleech
Aug 15 2017 12:25
so, subscribe in the test and then test the result?
Rafael George
@cored
Aug 15 2017 12:25
but it would be with dry-transaction; I tested in the past with wisper-rspec just asserting on triggering the actual event that I wanted
yeap
my service objects normally don't mutate state on whatever you past into it so I return something that I call a view model which is a transformation that represents the side effect, I use wisper to publish taht side effect to the rest of the system so I avoid the coupling between service objects\
since my service objects return the transformation I just have to assert on those values on the subscribed block
It records all events and payloads. You could do this.
I have to go and get lunch now, bbl
Rafael George
@cored
Aug 15 2017 12:28
enjoy
and thanks for the hint
Kris Leech
@krisleech
Aug 15 2017 13:03
no problem