Materializers are hooks over the lifecycle of an actor. They are used to add implicit infrastructure logic to an actor. Some use case of materializers are, actually, two main tarant modules tarant-vue and tarant-local-storage that let us render actors and save their state in the local storage of the browser, for later recovery.
A materializer can implement the following methods:
onInitialize(actor: Actor)when the actor is first created.
onBeforeMessage(actor: Actor, message: ActorMessage): voidwhen the actor is going to process a message.
onAfterMessage(actor: Actor, message: ActorMessage): voidafter a message has been processed succesfully.
onError(actor: Actor, message: ActorMessage, error: any): voidwhen processing a message failed. You can not recover from the error from here, for that, you need to use supervisors.