Cysharp/MessagePipe

Is RequestHandler stateless?

AGeorgy opened this issue · 1 comments

Am I realized correctly that IRequestHandler<, > class is stateless? I would like to have IRequestHandler singleton with its own state. But IRequestHandler seams to creating inside of BuildServiceProvider. Can I make it outside and just somehow register?
Example:

public class ToDoServiceHandlers : MonoBehaviour,
        IRequestHandler<InitialStateRequest, InitialStateResponse>,
        IRequestHandler<ClearItemsRequest, ClearItemsResponse>,
        IRequestHandler<AddItemRequest, AddItemResponse>
    {
        private ToDoState _model;

        private void Awake()
        {
            _model = ToDoState.InitialState;;
        }

        public InitialStateResponse Invoke(InitialStateRequest request)
        {
            var response = GlobalMessagePipe.GetRequestHandler<LoadToDoItemsRequest, LoadToDoItemsResponse>().Invoke(default);

            _model.Items = response.Value;
            return new InitialStateResponse {Value = _model.Items};
        }
        }

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 7 days.