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

Question on program flow and resolving dependencies #1

Closed
nkconnor opened this issue Jul 2, 2020 · 2 comments
Closed

Question on program flow and resolving dependencies #1

nkconnor opened this issue Jul 2, 2020 · 2 comments

Comments

@nkconnor
Copy link

nkconnor commented Jul 2, 2020

Is there a method to resolve some component from the System or is the expected workflow to kick-off a program in an associated Lifecycle? E.g. the later,

#[derive(Component)]
struct StartProgram { }

#[async_trait]
impl ComponentLifecycle for StartProgram {
    async start(&mut self) {
       // start main program logic and add injected stuff to StartProgram constructor
@zhming0
Copy link
Owner

zhming0 commented Jul 3, 2020

Is there a method to resolve some component from the System

There is no public method for this at this moment. In the future, I might add it for testing purpose.

is the expected workflow to kick-off a program in an associated Lifecycle?

Hmmmmm, I am not 100% following the question.
A program should kick-off a System and the system will initialize & start all components.

#[derive(Component)]
#[lifecycle]
struct StartProgram { 
    #[injected]
    stuff: Injected<SomeType>
}

#[async_trait]
impl ComponentLifecycle for StartProgram {
    async start(&mut self) {
       // At this point, all dependency of StartProgram would have been initialized & started. 
       self.stuff.do_something();

@nkconnor
Copy link
Author

nkconnor commented Jul 3, 2020

you answered my questions, thank you!

@zhming0 zhming0 closed this as completed Jul 3, 2020
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