How to separate code from the ux file?

What if I plan on writing a big project, and I don’t want all the code inside the main ux file… is there a way of creating an external code file (like .cs or something) and reference to it?

Hi!

You can make multiple .ux files and just cut parts of your main UX file into there. The separate UX-file becomes a class that you can instantiate anywhere.

Example, old main UX file:

<Foo>
    <Bar>
        <Moo />
    </Bar>
</Foo>

Say I cut the <Bar>..</Bar> code and put it in MyBar.ux:

<Bar>
    <Moo />
</Bar>

Then I can change my main UX file to:

 <Foo>
     <MyBar />
 </Foo>

And how could a comunicate animate an element that is on MainView.ux, from MyBar.ux. Lets say i want to animate and image when i click on a button on MyBar. Is that possible?

+1

For now you have to use JavaScript to communicate between different UX files.

We have features in an upcoming release that’ll address these questions, and we’ll update the learn-section with some best practices too.