Thanks, Derek

On Sun, Apr 10, 2016 at 2:02 PM, Derek Wyatt <de...@derekwyatt.org> wrote:

> Alright. I'll play around with these over the next few days and send you a
> PR.
>
> On Fri, Apr 8, 2016 at 12:12 PM Patrik Nordwall <patrik.nordw...@gmail.com>
> wrote:
>
>> Hi Derek,
>> Sounds like a great addition. Will you take a stab at it?
>> /Patrik
>>
>> On Thu, Apr 7, 2016 at 9:59 PM, Derek Wyatt <de...@derekwyatt.org> wrote:
>>
>>> Hi guys,
>>>
>>> I've been writing some tests for my stream code and have run up against
>>> a situation where I would like to have expectNextType.  I've
>>> implemented this myself with a pimp, but I'm wondering if there's a better
>>> way?
>>>
>>>   implicit class ProbeExtension[T](val p: Probe[T]) {
>>>     def expectNextType[A](implicit t: ClassTag[A]): p.Self = {
>>>       p.expectNextPF {
>>>         case a: A =>
>>>         case x => fail(s"Expected a $t type but got a
>>> ${x.getClass.getName}")
>>>       }
>>>       p
>>>     }
>>>   }
>>>
>>> This is mostly useful when the 'A' in question is a derivation of Try[_].
>>> I tend to write expectNextType[Failure[_]] in these cases.  And, just
>>> to give some context as to why I would want to do that: My flow components
>>> might return a Try, which I then pass through a special handling / logging
>>> flow, which transforms them to a List that is composed with a mapConcat.
>>> So...
>>>
>>> val flowReturningTry: Flow[T, Try[U], NotUsed] = ...
>>> val handlingAndLogging: Flow[Try[U], U, NotUsed] =
>>> Flow[Try[U]].mapConcat { /* List(u) or List(), depending on the Try */ }
>>> val composed: Flow[T, U, NotUsed] =
>>> flowReturningTry.mapConcat(handlingAndLogging)
>>>
>>> Now, when testing flowReturningTry in isolation, the expectNextType is
>>> useful.
>>>
>>> Cheers and thanks,
>>> Derek
>>>
>> --
>>> >>>>>>>>>> Read the docs: http://akka.io/docs/
>>> >>>>>>>>>> Check the FAQ:
>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>> >>>>>>>>>> Search the archives:
>>> https://groups.google.com/group/akka-user
>>> ---
>>>
>> You received this message because you are subscribed to the Google Groups
>>> "Akka User List" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to akka-user+unsubscr...@googlegroups.com.
>>
>>
>>> To post to this group, send email to akka-user@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/akka-user.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> --
>>
>> Patrik Nordwall
>> Akka Tech Lead
>> Lightbend <http://www.lightbend.com/> -  Reactive apps on the JVM
>> Twitter: @patriknw
>>
>> --
>> >>>>>>>>>> Read the docs: http://akka.io/docs/
>> >>>>>>>>>> Check the FAQ:
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
>> ---
>> You received this message because you are subscribed to a topic in the
>> Google Groups "Akka User List" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/akka-user/ySk9lP-TZQU/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> akka-user+unsubscr...@googlegroups.com.
>> To post to this group, send email to akka-user@googlegroups.com.
>> Visit this group at https://groups.google.com/group/akka-user.
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> >>>>>>>>>> Read the docs: http://akka.io/docs/
> >>>>>>>>>> Check the FAQ:
> http://doc.akka.io/docs/akka/current/additional/faq.html
> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
> ---
> You received this message because you are subscribed to the Google Groups
> "Akka User List" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to akka-user+unsubscr...@googlegroups.com.
> To post to this group, send email to akka-user@googlegroups.com.
> Visit this group at https://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>



-- 

Patrik Nordwall
Akka Tech Lead
Lightbend <http://www.lightbend.com/> -  Reactive apps on the JVM
Twitter: @patriknw

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to