符合Applicative类型类.它位于Control.Applicative模块中,它定义了两种方法
pure and <*>.它没有为它们中的任何一个提供默认实现,因此如果我们想要某些东西成为一个applicative functor,我们必须定义它们.
我试图了解谁在使用pure功能.我确实使用(<*>)了应用函子最有用的函数.但我不确定谁真正使用pure.
我读过类似的东西,pure (+3) <*> Just 10但它也可以写成Just (+3) <*> Just 10.
以上只是我有太多困惑.定义的真正目的是什么?pure何时使用它(或)已经使用它?
我的Aggregate礼品卡定义如下,
@Data
@NoArgsConstructor
@Aggregate
public class GiftCard {
@AggregateIdentifier
private String id;
private int remainingValue;
@CommandHandler
public GiftCard(IssueCardCommand cmd) {
apply(new CardIssuedEvent(cmd.getCardId(), cmd.getAmount()));
}
@CommandHandler
public GiftCard(TempCommand cmd) {
apply(new CardIssuedEvent(cmd.getCardId(), cmd.getAmount()));
}
@EventSourcingHandler
public void on(CardIssuedEvent event) {
this.id = event.getCardId();
this.remainingValue = event.getAmount();
}
}
Run Code Online (Sandbox Code Playgroud)
我IssueCardCommand从控制器调度。
public String createGreeting(@PathVariable String cardNumber) {
IssueCardCommand issueCardCommand = new IssueCardCommand(cardNumber, 100);
commandGateway.sendAndWait(issueCardCommand, 500L, TimeUnit.MILLISECONDS);
return "Hey";
}
Run Code Online (Sandbox Code Playgroud)
我可以通过http://localhost:8024/#query在 AxonServer 中查看来确认已调度事件。
我想做 EventSourcing 并设置了内存中的 H2 数据库。 …