Skip to content

How to deal with callbacks in nested component. #6733

Answered by ogoffart
laycookie asked this question in Q&A
Discussion options

You must be logged in to vote

Two ways:

  1. forward the callback to the root:
export component MainWindow inherits Window {
    callback add_token(string);
    in-out property <Pages> current_page: Pages.Login;

    if (current_page == Pages.Login): LoginForm {
        add_token(str) => { root.add_token(str); }
//...
  1. Or alternatively, use a global:
export global LoginFormLogic {
    callback add_token(string);
}

component LoginForm {
    in property <string> service;
    out property <string> token: "";
    
    VerticalBox {
        Text {
            text: root.service;
        }
        LineEdit {
            text: root.token;
            placeholder-text: "Token";
        }
        Button {
            text: "Login"

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by laycookie
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