示例#1
0
        public static CommandQuery FromEvent <TEvent>(this CommandQueryBuilder builder, Task <TEvent> currentValue, Func <TEvent?, bool> check)
            where TEvent : class
        {
            var context = ExposedReceiveActor.ExposedContext;

            return(builder.FromExternal(check, action =>
            {
                currentValue.ContinueWith(t =>
                {
                    if (t.IsCompleted)
                    {
                        action(t.Result);
                    }
                });

                context.ActorOf(dsl =>
                {
                    dsl.OnPreStart += actorContext => actorContext.System.EventStream.Subscribe <TEvent>(actorContext.Self);
                    dsl.OnPostStop += actorContext => actorContext.System.EventStream.Unsubscribe(actorContext.Self);
                    dsl.Receive <TEvent>((e, c) => action(e));
                });
            }));
        }
示例#2
0
 public static CommandQuery FromEventSource <TData>(this CommandQueryBuilder builder, IEventSource <TData> source, Func <TData, bool> check)
     where TData : class
 => builder.FromExternal <TData>(d => d != null && check(d), action => source.RespondOn(ActorCell.GetCurrentSelfOrNoSender() ?? ActorRefs.Nobody, action));
示例#3
0
 public static CommandQuery FromEventSource <TData>(this CommandQueryBuilder builder, IEventSource <TData> source, Func <TData, bool> check, TData defaultValue)
 => builder.FromExternal(check, action => source.RespondOn(ActorCell.GetCurrentSelfOrNoSender() ?? ActorRefs.Nobody, action), defaultValue);