Skip to content

docs: Scala Replicated Entity docs#635

Merged
johanandren merged 1 commit intomainfrom
wip-re-docs-patriknw
Oct 15, 2021
Merged

docs: Scala Replicated Entity docs#635
johanandren merged 1 commit intomainfrom
wip-re-docs-patriknw

Conversation

@patriknw
Copy link
Copy Markdown
Contributor

  • includes the first part, Shopping Cart sample

* includes the first part, Shopping Cart sample
== Implementing behavior

A Replicated Entity implementation is a Java class where you define how each command is handled. The class `ShoppingCart` gets generated for us based on the `shoppingcart_api.proto` and `shoppingcart_domain.proto` definitions. Once the `ShoppingCart.java` file exist, it is not overwritten, so you can freely add logic to it. `ShoppingCart` extends the generated class `AbstractShoppingCart` which we're not supposed to change as it gets regenerated in case we update the protobuf descriptors. `AbstractShoppingCart` contains all method signatures corresponding to the API of the service. If you change the API you will see compilation errors in the `ShoppingCart` class and you have to implement the methods required by `AbstractShoppingCart`.
A Replicated Entity implementation is a Java class where you define how each command is handled. The class `ShoppingCart` gets generated for us based on the `shoppingcart_api.proto` and `shoppingcart_domain.proto` definitions. Once the [.group-java]#`ShoppingCart.java`# [.group-scala]# file `ShoppingCart.scala`# exist, it is not overwritten, so you can freely add logic to it. `ShoppingCart` extends the generated class `AbstractShoppingCart` which we're not supposed to change as it gets regenerated in case we update the protobuf descriptors. `AbstractShoppingCart` contains all method signatures corresponding to the API of the service. If you change the API you will see compilation errors in the `ShoppingCart` class and you have to implement the methods required by `AbstractShoppingCart`.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, neat, I didn't know it is possible to switch in-text-things with [.group-java]# like that

@johanandren johanandren merged commit 7add872 into main Oct 15, 2021
@johanandren johanandren deleted the wip-re-docs-patriknw branch October 15, 2021 09:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants