-
Hello, I am experimenting with slint and came across a generic issue I have when separating Application/Backend logic from the UI. The way to go seems as in the example a global component (which sadly cannot contain sub components). I have multiple issues, so I have to resort to hacks like my simple example below.
export global BackendImpl {
// --- actual property values - ohly to utilized within glue code.
in-out property <int> my-value;
}
export global Backend {
// --- properties for bindings within the UI
out property <int> my-value: BackendImpl.my-value;
// --- functions (if applicable) to set properties from within the UI
// --- this guarantees that the glue code UI <> Backend is (can be) notified
pure callback write-my-value(int);
} Is there a better solution? this seems so 'hacky'. |
Beta Was this translation helpful? Give feedback.
Answered by
ogoffart
Dec 27, 2023
Replies: 1 comment 2 replies
-
This is the way I recommend to do it, yes. I'd even put a default implementation so it works in the preview without the backend: export global Backend {
in-out property <int> my-value;
pure callback write-my-value(int);
// default implementation that can be overridden by the backend
write-my-value(x) => { my-value = x; }
} |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
jahnf
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is the way I recommend to do it, yes.
I'd even put a default implementation so it works in the preview without the backend: