2

Im thinking how can I spawn an actor with some additional parameters in F# ?

I have the following actor function definition

let triggerActor (mailbox: Actor<TriggerCommand>) (name: string, expr : string, jobCallback : JobCallback) =

(...... cutted code, not needed here  )

and Im trying to wrap that function to spawn an actor with

spawn system name (actorOf2 triggerActor    )

but here I run into a troubles... how can I pass those additional params? I know that I can create a custom C# style actor, but for now I want to try with F# :)

4

1 回答 1

6

I'm not an expert on Akka, but assuming the "extra parameters" are the second argument you can do as follows.

First reverse the order of the formal parameters:

let triggerActor (name: string, expr : string, jobCallback : JobCallback) (mailbox: Actor<TriggerCommand>) = ...

Then partially apply the function:

spawn system name (actorOf2 (triggerActor ("name", "expr", jc )))
于 2015-05-24T13:51:01.793 回答