yewstack/docs

Add a diagram of the Agent lifecycle

jstarry opened this issue · 2 comments

DOC TODO: https://yew.rs/docs/concepts/agents#lifecycle

Describe the lifecycle methods of an Agent and the lifetime of each type of Agent (Job, Context, Private, Public)

    /// Creates an instance of an agent.
    fn create(link: AgentLink<Self>) -> Self;

    /// This method called on every update message.
    fn update(&mut self, msg: Self::Message);

    /// This method called on when a new bridge created.
    fn connected(&mut self, _id: HandlerId) {}

    /// This method called on every incoming message.
    fn handle_input(&mut self, msg: Self::Input, id: HandlerId);

    /// This method called on when a new bridge destroyed.
    fn disconnected(&mut self, _id: HandlerId) {}

    /// This method called when the agent is destroyed.
    fn destroy(&mut self) {}

I'm not exactly sure where all the arrows should go, but would a diagram like this do the trick?
Diagram.
The diagram was made with nomnoml.com.

Thanks @teymour-aldridge this is a good start! It'd be great if this was added to the docs :)