Thanks again for a very prompt reply.
Guillaume. 

On Friday, January 17, 2014 11:12:22 AM UTC+2, √ wrote:
>
>
>
>
> On Fri, Jan 17, 2014 at 9:43 AM, Guillaume Belrose 
> <[email protected]<javascript:>
> > wrote:
>
>> Hi all, 
>>
>> I am working on a video recoding application with Akka and I have a bunch 
>> of actors which share a bit of information, namely how to start a recording.
>>
>> There are different ways of starting a recording, so I use a base trait 
>> and specific case classes. 
>>
>> For example:
>> sealed trait StartRecording
>>
>> /** Start recording at a given date*/
>> case class StartRecordingByDate(date: Long) extends StartRecording
>>
>> /** Start recording straight away*/
>> case object StartRecordingStraightAway extends StartRecording
>>
>> I want to be able to mutate how a recording start (i.e. update the start 
>> time, or even better change the start record mode), so I was thinking of 
>> using an Agent[StartRecording]. However, Agents are invariant so this does 
>> not really work.
>>
>> One option is was thinking about is to have a wrapper and create an agent 
>> for that wrapper, like so:
>>
>> case class Wrapper(wrapped: StartRecording)
>>
>> val agent = Agent(Wrapper(StartRecordingStraighAway))
>>
>
> val agent = Agent[StartRecording](StartRecordingStraightAway))
>  
>
>>
>> This compiles and work, but I am wondering if it is a good idea or if 
>> there is a better way.
>>
>> Guillaume.
>>
>> PS: Here is a working code example:
>>
>> package org.kafecho.learning.akka
>>
>>
>> import akka.actor.ActorSystem
>>
>> import akka.agent.Agent
>>
>>
>> object AgentTest extends App{
>>
>> sealed trait StartRecording
>>  
>>
>> /** Start recording at a given date*/
>>
>> case class StartRecordingByDate(date: Long) extends StartRecording
>>
>>
>> /** Start recording straight away*/
>>
>> case object StartRecordingStraightAway extends StartRecording
>>
>>
>> implicit val system = ActorSystem("Agents")
>>  
>>
>> val agent = Agent(StartRecordingStraightAway)
>>
>>
>> // This does not compile
>>
>> //agent.update(StartRecordingByDate(System.currentTimeMillis() + 1000))
>>
>>
>> case class Wrapper(startRecording: StartRecording)
>>
>>
>> // This compiles, but is it a good idea?
>>
>> val agent2 = Agent(Wrapper(StartRecordingStraightAway))
>>
>> agent2.update(Wrapper(StartRecordingByDate(System.currentTimeMillis() + 
>> 1000)))
>>
>> }
>>  
>>
>>
>>  -- 
>> >>>>>>>>>> Read the docs: http://akka.io/docs/
>> >>>>>>>>>> Check the FAQ: http://akka.io/faq/
>> >>>>>>>>>> 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 [email protected] <javascript:>.
>> To post to this group, send email to [email protected]<javascript:>
>> .
>> Visit this group at http://groups.google.com/group/akka-user.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>
>
> -- 
> Cheers,
> √
>
> * Viktor Klang*
> *Concurrent, Distributed*
>
> Twitter: @viktorklang
>  

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: http://akka.io/faq/
>>>>>>>>>>      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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to