Skip to content

how to stop the reactive system on v0.5? #1563

Answered by gbj
flisky asked this question in Q&A
Discussion options

You must be logged in to vote

Conceptually, when you're using a reactive system like this one your whole application should be a set of nested effects, so mounting or unmounting a component should be managed by some kind of effect. Here's an example using some GUI pseudo-code:

let (show_component, set_show_component) = create_signal(false);

let container = Container::new();

create_effect(move |_| {
  if show_component() {
    container.append_child(some_component());
  } else {
    container.clear();
  }
});

fn some_component() -> Widget {
  let (data, set_data) = create_signal();
  create_effect(move |_| {
    println!("{}", data());
  });
  // return the widget
  todo!()
}

In this case, what owns the signal and t…

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@flisky
Comment options

@gbj
Comment options

@flisky
Comment options

@gbj
Comment options

Answer selected by flisky
@flisky
Comment options

@gbj
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants