Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Experiment with a functional API #128

Open
thomaseizinger opened this issue Jul 15, 2022 · 2 comments
Open

Experiment with a functional API #128

thomaseizinger opened this issue Jul 15, 2022 · 2 comments

Comments

@thomaseizinger
Copy link
Collaborator

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?

@Restioson
Copy link
Owner

Restioson commented Jul 16, 2022

Hmm, this could be interesting, but it would probably lead to explosive compile times 😅 The upshot is that it could be done in an extension crate, though.

@thomaseizinger
Copy link
Collaborator Author

Hmm, this could be interesting, but it would probably lead to explosive compile times sweat_smile The upshot is that it could be done in an extension crate, though.

Yeah definitely in an extension crate.

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

No branches or pull requests

2 participants