Skip to content

Experiment with a functional API #128

Description

@thomaseizinger

This is probably more something to be added in an extension crate, but it would be cool to be able to define actors from closures:

let initial_state = 0u64;
xtra::actor::unbounded(initial_state)
  .handle(|name: String, ctx: &mut Context| async move {
     format!("Hello {name}")
  });

Not sure how nameable the actor type would be (some nested AndHandler<HandlerFn<String, String>, AndHandler<HandlerFn<u64, u64>>> stuff probably) so perhaps one would only be able to access such an actor through MessageChannels?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions