-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Agent v2 #1708
Comments
In addition to the leading suggested changes, I think we should split the Agent trait into two variants like We could use a blanket trait to implement a single /// An agent that consumes a value.
pub trait AgentCast<IN> {
fn create(link: AgentLink<Self>) -> Self;
// ...other general agent functions, if needed.
fn cast(&mut self, input: IN);
}
/// An agent that consumes a value and returns a new value.
pub trait AgentCall<IN> {
type Output;
fn create(link: AgentLink<Self>) -> Self;
// ...other general agent functions, if needed.
fn call(&mut self, input: IN) -> Self::Output;
// this might look closer to this when it is implemented:
// fn call(&mut self, input: IN)
}
/// An agent.
#[doc(hidden)]
pub trait Agent {
fn create(link: AgentLink<Self>) -> Self;
// ...other general agent functions, if needed.
}
// these blanket implementations abstract away the hassle of having to
// implement two traits from the programmer, so they can focus more on
// the implementation
impl<T, IN> Agent for T
where T: AgentCast<IN> {
fn create(link: AgentLink<Self>) -> Self {
<Self as AgentCast<IN>>::create(link)
}
// ...other general agent functions, if needed.
}
impl<T, IN> Agent for T
where T: AgentCall<IN> {
fn create(link: AgentLink<Self>) -> Self {
<Self as AgentCall<IN>>::create(link)
}
// ...other general agent functions, if needed.
} I'm not too knowledgeable about the internals yet, so excuse my assumptions. |
Irrelevant since agents aren't implemented by Yew. The improvement will be in gloo. See #2326 |
Problem
The current
Agent
trait API includes a way to handle "messages" and "input" and it's not immediately clear when to use each of these. Messages are unidirectional and primarily intended for internal agent usage. Input messages are for bidirectional communication and have a corresponding output message type and are intended for external client usage.Suggested Changes
AgentLink
AgentLink
The text was updated successfully, but these errors were encountered: